Method: Roby::Queries::TaskMatcher#with_arguments
- Defined in:
- lib/roby/queries/task_matcher.rb
#with_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. Unlike #with_model_arguments, all values set in arguments
are considered.
See also #with_model_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_arguments(a: 10) === task # => true
# Looks for both :a and :b
TaskMatcher.new.
with_arguments(a: 10, b: 30) === task # => false
# Looks for both :a and :c, even though :c is not declared in TaskModel
TaskMatcher.new.
with_arguments(a: 10, c: 30) === task # => false
135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/roby/queries/task_matcher.rb', line 135 def with_arguments(arguments) @arguments ||= {} @indexed_query = false self.arguments.merge!(arguments) do |k, old, new| if old != new raise ArgumentError, "a constraint has already been set on the #{k} argument" end old end self end |