NodeSubscription

class
Superclass
Arborist::Subscription

An inter-node event subscription

Attributes

node[R]

The target node

Public Class Methods

anchor
new( node )

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

# File lib/arborist/node_subscription.rb, line 12
def initialize( node )
        @node = node
        super()
end

Public Instance Methods

anchor
check_callback()

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

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

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

Return the identifier of the subscribed node.

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

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