Class: OpenHAB::Core::Events::AbstractEvent
- Inherits:
-
Object
- Object
- OpenHAB::Core::Events::AbstractEvent
- Defined in:
- lib/openhab/core/events/abstract_event.rb
Overview
Add attachments event data.
Direct Known Subclasses
AbstractItemChannelLinkRegistryEvent, AbstractItemRegistryEvent, AbstractThingRegistryEvent, ChannelTriggeredEvent, ItemEvent, StartlevelEvent, ThingStatusInfoChangedEvent, ThingStatusInfoEvent, TimerEvent
Instance Attribute Summary collapse
- #attachment ⇒ Object readonly
- #inputs ⇒ Hash readonly
-
#source ⇒ Source?
readonly
The component(s) that sent the event.
Instance Method Summary collapse
- #inspect ⇒ String
-
#payload ⇒ Hash, ...
Returns the event payload as a Hash.
Instance Attribute Details
#attachment ⇒ Object
11 12 13 |
# File 'lib/openhab/core/events/abstract_event.rb', line 11 def attachment @attachment end |
#inputs ⇒ Hash
14 15 16 |
# File 'lib/openhab/core/events/abstract_event.rb', line 14 def inputs @inputs end |
#source ⇒ Source? (readonly)
Returns The component(s) that sent the event.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/openhab/core/events/abstract_event.rb', line 38 def source unless instance_variable_defined?(:@source) begin # Disable "instance vars on non-persistent Java type" original_verbose = $VERBOSE $VERBOSE = nil @source = get_source && Source.new(get_source) ensure $VERBOSE = original_verbose end end @source end |
Instance Method Details
#inspect ⇒ String
71 72 73 74 75 |
# File 'lib/openhab/core/events/abstract_event.rb', line 71 def inspect s = "#<OpenHAB::Core::Events::#{self.class.simple_name} topic=#{topic} payload=#{payload.inspect}" s += " source=#{source.inspect}" if source "#{s}>" end |
#payload ⇒ Hash, ...
Returns the event payload as a Hash.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/openhab/core/events/abstract_event.rb', line 58 def payload require "json" # Disable "instance vars on non-persistent Java type" original_verbose = $VERBOSE $VERBOSE = nil @payload ||= JSON.parse(get_payload, symbolize_names: true) unless get_payload.empty? rescue JSON::ParserError get_payload ensure $VERBOSE = original_verbose end |