Method: Roby::Queries::TaskMatcher#with_model_arguments

Defined in:
lib/roby/queries/task_matcher.rb

#with_model_arguments(arguments) ⇒ Object

Filters on the arguments that are declared in the model

Will match if the task arguments for which there is a value in arguments are set to that very value, only looking at arguments that are defined in the model set by #with_model.

See also #with_arguments

Example:

class TaskModel < Roby::Task
  argument :a
  argument :b
end
task = TaskModel.new(a: 10, b: 20)

# Matches on :a, :b is ignored altogether
TaskMatcher.new.
    with_model(TaskModel).
    with_model_arguments(a: 10) === task # => true
# Looks for both :a and :b
TaskMatcher.new.
    with_model(TaskModel).
    with_model_arguments(a: 10, b: 30) === task # => false
# Matches on :a, :c is ignored as it is not an argument of +TaskModel+
TaskMatcher.new.
    with_model(TaskModel).
    with_model_arguments(a: 10, c: 30) === task # => true

In general, one would use #which_fullfills, which sets both the model and the model arguments



102
103
104
105
106
107
108
# File 'lib/roby/queries/task_matcher.rb', line 102

def with_model_arguments(arguments)
    valid_arguments = model.inject([]) do |set, model|
        set | model.arguments.to_a
    end
    with_arguments(arguments.slice(*valid_arguments))
    self
end