class Roby::DelayedArgumentFromObject
Placeholder that can be used to assign an argument from an object's attribute, reading the attribute only when the task is started
This will usually not be used directly. One should use Task.from instead
Public Class Methods
new(object, weak = true)
click to toggle source
# File lib/roby/task_arguments.rb, line 289 def initialize(object, weak = true) @object = object @methods = [] @expected_class = Object @weak = weak end
Public Instance Methods
==(other)
click to toggle source
# File lib/roby/task_arguments.rb, line 344 def ==(other) other.kind_of?(DelayedArgumentFromObject) && @object.object_id == other.instance_variable_get(:@object).object_id && @methods == other.instance_variable_get(:@methods) end
evaluate_delayed_argument(task)
click to toggle source
# File lib/roby/task_arguments.rb, line 301 def evaluate_delayed_argument(task) result = @methods.inject(@object || task) do |v, m| if v.kind_of?(Roby::Task) && v.model.has_argument?(m) # We are trying to access a task argument, throw no_value if the # argument is not set if !v.arguments.has_key?(m) throw :no_value end argument = v.arguments.values[m] if TaskArguments.delayed_argument?(argument) argument.evaluate_delayed_argument(v) else argument end elsif v.respond_to?(m) begin v.send(m) rescue Exception throw :no_value end elsif @weak throw :no_value else task.failed_to_start!("#{v} has no method called #{m}") throw :no_value end end if @expected_class && !result.kind_of?(@expected_class) throw :no_value end result end
method_missing(m, *args)
click to toggle source
Calls superclass method
# File lib/roby/task_arguments.rb, line 335 def method_missing(m, *args) if args.empty? && !block_given? @methods << m self else super end end
of_type(expected_class)
click to toggle source
# File lib/roby/task_arguments.rb, line 296 def of_type(expected_class) @expected_class = expected_class self end
pretty_print(pp)
click to toggle source
# File lib/roby/task_arguments.rb, line 354 def pretty_print(pp) pp.text to_s end
to_s()
click to toggle source
# File lib/roby/task_arguments.rb, line 350 def to_s "delayed_argument_from(#{@object || 'task'}.#{@methods.map(&:to_s).join(".")})" end