module Roby::Models::PlanObject
Public Instance Methods
child_plan_object(attribute)
click to toggle source
This class method sets up the enclosing class as a child object, with the root object being returned by the given attribute. Task
event generators are for instance defined by
class TaskEventGenerator < EventGenerator # The task this generator belongs to attr_reader :task child_plan_object :task end
# File lib/roby/models/plan_object.rb, line 44 def child_plan_object(attribute) class_eval <<-EOD, __FILE__, __LINE__+1 def root_object; #{attribute} end def root_object?; false end def owners; #{attribute}.owners end def distribute?; #{attribute}.distribute? end def plan; #{attribute}.plan end def executable?; #{attribute}.executable? end def subscribed?; #{attribute}.subscribed? end def updated?; #{attribute}.updated? end def updated_by?(peer); #{attribute}.updated_by?(peer) end def update_on?(peer); #{attribute}.update_on?(peer) end def updated_peers; #{attribute}.updated_peers end def remotely_useful?; #{attribute}.remotely_useful? end def forget_peer(peer) remove_sibling_for(peer) end def sibling_of(remote_object, peer) if !distribute? raise ArgumentError, "#{self} is local only" end add_sibling_for(peer, remote_object) end private :plan= private :executable= EOD end
match()
click to toggle source
Create a {Queries::PlanObjectMatcher}
# File lib/roby/models/plan_object.rb, line 77 def match Queries::PlanObjectMatcher.new.with_model(self) end
when_finalized(&block)
click to toggle source
Adds a model-level finalization handler, i.e. a handler that will be called on every instance of the class
The block is called in the context of the task that got finalized (i.e. in the block, self is this task)
@return [void]
# File lib/roby/models/plan_object.rb, line 20 def when_finalized(&block) method_name = "finalization_handler_#{block.object_id}" define_method(method_name, &block) finalization_handlers << instance_method(method_name) end