Node

class
Superclass
Arborist::Event

A base class for events which are related to an Arborist::Node.

Attributes

node[R]

The node that generated the event

Public Class Methods

anchor
new( node, payload=nil )

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

Public Instance Methods

anchor
match( object )

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
anchor
payload()

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
anchor
to_h()

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