Class: Arborist::Event::Node
- Inherits:
-
Arborist::Event
- Object
- Arborist::Event
- Arborist::Event::Node
- Defined in:
- lib/arborist/event/node.rb
Overview
A base class for events which are related to an Arborist::Node.
Direct Known Subclasses
NodeAcked, NodeDelta, NodeDisabled, NodeDown, NodeQuieted, NodeUnknown, NodeUp, NodeUpdate, NodeWarn
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
The node that generated the event.
Instance Method Summary collapse
-
#initialize(node, payload = nil) ⇒ Node
constructor
Strip and save the node argument to the constructor.
-
#inspect_details ⇒ Object
Return the detail portion of the #inspect string appropriate for this event type.
-
#match(object) ⇒ Object
Returns
true
if the specifiedobject
matches this event. -
#payload ⇒ Object
Use the node data as this event’s payload.
-
#to_h ⇒ Object
Inject useful node metadata into the generated hash.
Methods inherited from Arborist::Event
#informational?, #inspect, #type
Constructor Details
#initialize(node, payload = nil) ⇒ Node
Strip and save the node argument to the constructor.
11 12 13 14 |
# File 'lib/arborist/event/node.rb', line 11 def initialize( node, payload=nil ) @node = node super( payload ) end |
Instance Attribute Details
#node ⇒ Object (readonly)
The node that generated the event
22 23 24 |
# File 'lib/arborist/event/node.rb', line 22 def node @node end |
Instance Method Details
#inspect_details ⇒ Object
Return the detail portion of the #inspect string appropriate for this event type.
42 43 44 45 46 47 48 |
# File 'lib/arborist/event/node.rb', line 42 def inspect_details return "%s(%s)%s" % [ self.node.identifier, self.node.type, self.node.flapping? ? ' (flapping)' : '', ] end |
#match(object) ⇒ Object
Returns true
if the specified object
matches this event.
26 27 28 29 30 31 32 |
# File 'lib/arborist/event/node.rb', line 26 def match( object ) rval = super && self.node.matches?( object.criteria ) && !self.node.matches?( object.negative_criteria, if_empty: false ) self.log.debug "Node event #match: %p" % [ rval ] return rval end |
#payload ⇒ Object
Use the node data as this event’s payload.
36 37 38 |
# File 'lib/arborist/event/node.rb', line 36 def payload return self.node.to_h end |
#to_h ⇒ Object
Inject useful node metadata into the generated hash.
52 53 54 55 56 57 58 59 |
# File 'lib/arborist/event/node.rb', line 52 def to_h return super.merge( identifier: self.node.identifier, parent: self.node.parent, nodetype: self.node.type, flapping: self.node.flapping? ) end |