class Arborist::NodeSubscription

An inter-node event subscription

Attributes

node[R]

The target node

Public Class Methods

new( node ) click to toggle source

Create a new subscription object that will send events to the given node.

Calls superclass method Arborist::Subscription::new
# File lib/arborist/node_subscription.rb, line 12
def initialize( node )
        @node = node
        super()
end

Public Instance Methods

check_callback() click to toggle source

Check the node to make sure it can handle published events.

# File lib/arborist/node_subscription.rb, line 40
def check_callback
        raise NameError, "node doesn't implement handle_event" unless
                self.node.respond_to?( :handle_event )
end
generate_id() click to toggle source

Return an ID derived from the node's identifier.

# File lib/arborist/node_subscription.rb, line 34
def generate_id
        return "%s-subscription" % [ self.node_identifier ]
end
inspect() click to toggle source

Return a String representation of the object suitable for debugging.

# File lib/arborist/node_subscription.rb, line 55
def inspect
        return "#<%p:%#x for the %s node>" % [
                self.class,
                self.object_id * 2,
                self.node.identifier,
        ]
end
node_identifier() click to toggle source

Return the identifier of the subscribed node.

# File lib/arborist/node_subscription.rb, line 28
def node_identifier
        return self.node.identifier
end
on_events( *events ) click to toggle source

Publish any of the specified events which match the subscription.

# File lib/arborist/node_subscription.rb, line 47
def on_events( *events )
        events.flatten.each do |event|
                self.node.handle_event( event )
        end
end