A base class for events which are related to an Arborist::Node.
The node that generated the event
Strip and save the node argument to the constructor.
# File lib/arborist/event/node.rb, line 10
def initialize( node, payload=nil )
@node = node
super( payload )
end
Returns true
if the specified object
matches this
event.
# 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
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
Inject useful node metadata into the generated hash.
# File lib/arborist/event/node.rb, line 41
def to_h
return super.merge(
identifier: self.node.identifier,
parent: self.node.parent,
nodetype: self.node.type
)
end