Class: Arborist::Event
- Inherits:
-
Object
- Object
- Arborist::Event
- Extended by:
- Loggability, Pluggability
- Defined in:
- lib/arborist/event.rb
Overview
The representation of activity in the manager; events are broadcast when node state changes, when they’re updated, and when various other operational actions take place, e.g., the node tree gets reloaded.
Direct Known Subclasses
Defined Under Namespace
Classes: Node, NodeAcked, NodeDelta, NodeDisabled, NodeDown, NodeQuieted, NodeUnknown, NodeUp, NodeUpdate, NodeWarn
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
The event payload specific to the event type.
Instance Method Summary collapse
-
#informational? ⇒ Boolean
(also: #is_informational?)
Returns
trueif the event contains node information other than about a change in its state. -
#initialize(payload) ⇒ Event
constructor
Create a new event with the specified
payloaddata. -
#inspect ⇒ Object
Return a string representation of the object suitable for debugging.
-
#inspect_details ⇒ Object
Return the detail portion of the #inspect string appropriate for this event type.
-
#match(object) ⇒ Object
(also: #=~)
Match operator – returns
trueif the other object matches this event. -
#to_h ⇒ Object
Return the event as a Hash.
-
#type ⇒ Object
Return the type of the event.
Constructor Details
#initialize(payload) ⇒ Event
Create a new event with the specified payload data.
25 26 27 28 |
# File 'lib/arborist/event.rb', line 25 def initialize( payload ) payload = payload.clone unless payload.nil? @payload = payload end |
Instance Attribute Details
#payload ⇒ Object (readonly)
The event payload specific to the event type
36 37 38 |
# File 'lib/arborist/event.rb', line 36 def payload @payload end |
Instance Method Details
#informational? ⇒ Boolean Also known as: is_informational?
Returns true if the event contains node information other than about a change in its state.
50 51 52 |
# File 'lib/arborist/event.rb', line 50 def informational? return false end |
#inspect ⇒ Object
Return a string representation of the object suitable for debugging.
76 77 78 79 80 81 82 |
# File 'lib/arborist/event.rb', line 76 def inspect return "#<%p:%#016x %s>" % [ self.class, self.object_id * 2, self.inspect_details, ] end |
#inspect_details ⇒ Object
Return the detail portion of the #inspect string appropriate for this event type.
86 87 88 |
# File 'lib/arborist/event.rb', line 86 def inspect_details return self.payload.inspect end |
#match(object) ⇒ Object Also known as: =~
Match operator – returns true if the other object matches this event.
57 58 59 60 61 62 |
# File 'lib/arborist/event.rb', line 57 def match( object ) rval = object.respond_to?( :event_type ) && ( object.event_type.nil? || object.event_type == self.type ) self.log.debug "Base node #match: %p" % [ rval ] return rval end |
#to_h ⇒ Object
Return the event as a Hash.
67 68 69 70 71 72 |
# File 'lib/arborist/event.rb', line 67 def to_h return { type: self.type, data: self.payload } end |
#type ⇒ Object
Return the type of the event.
40 41 42 43 44 45 |
# File 'lib/arborist/event.rb', line 40 def type return self.class.name. sub( /.*::/, '' ). gsub( /([a-z])([A-Z])/, '\1.\2' ). downcase end |