class Arborist::Event
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.
Attributes
payload[R]
The event payload specific to the event type
Public Class Methods
new( payload )
click to toggle source
Create a new event with the specified payload
data.
# File lib/arborist/event.rb, line 24 def initialize( payload ) payload = payload.clone unless payload.nil? @payload = payload end
Public Instance Methods
informational?()
click to toggle source
Returns true
if the event contains node information other than about a change in its state.
# File lib/arborist/event.rb, line 49 def informational? return false end
Also aliased as: is_informational?
inspect()
click to toggle source
Return a string representation of the object suitable for debugging.
# File lib/arborist/event.rb, line 75 def inspect return "#<%p:%#016x %s>" % [ self.class, self.object_id * 2, self.inspect_details, ] end
inspect_details()
click to toggle source
Return the detail portion of the inspect
string appropriate for this event type.
# File lib/arborist/event.rb, line 85 def inspect_details return self.payload.inspect end
match( object )
click to toggle source
Match operator – returns true
if the other object matches this event.
# File lib/arborist/event.rb, line 56 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
Also aliased as: =~
to_h()
click to toggle source
Return the event as a Hash.
# File lib/arborist/event.rb, line 66 def to_h return { type: self.type, data: self.payload } end
type()
click to toggle source
Return the type of the event.
# File lib/arborist/event.rb, line 39 def type return self.class.name. sub( /.*::/, '' ). gsub( /([a-z])([A-Z])/, '\1.\2' ). downcase end