class Arborist::Event::Node
A base class for events which are related to an Arborist::Node
.
Attributes
node[R]
The node that generated the event
Public Class Methods
new( node, payload=nil )
click to toggle source
Strip and save the node argument to the constructor.
Calls superclass method
Arborist::Event::new
# File lib/arborist/event/node.rb, line 10 def initialize( node, payload=nil ) @node = node super( payload ) end
Public Instance Methods
inspect_details()
click to toggle source
Return the detail portion of the inspect
string appropriate for this event type.
# File lib/arborist/event/node.rb, line 41 def inspect_details return "%s(%s)%s" % [ self.node.identifier, self.node.type, self.node.flapping? ? ' (flapping)' : '', ] end
match( object )
click to toggle source
Returns true
if the specified object
matches this event.
Calls superclass method
Arborist::Event#match
# File lib/arborist/event/node.rb, line 25 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()
click to toggle source
Use the node data as this event's payload.
# File lib/arborist/event/node.rb, line 35 def payload return self.node.to_h end
to_h()
click to toggle source
Inject useful node metadata into the generated hash.
Calls superclass method
Arborist::Event#to_h
# File lib/arborist/event/node.rb, line 51 def to_h return super.merge( identifier: self.node.identifier, parent: self.node.parent, nodetype: self.node.type, flapping: self.node.flapping? ) end