Module: Roby::Models::Arguments
- Extended by:
- MetaRuby::Attributes
- Included in:
- Task, TaskServiceModel
- Defined in:
- lib/roby/models/arguments.rb
Overview
Support for argument handling in the relevant models (task services and tasks)
Defined Under Namespace
Classes: Argument
Constant Summary collapse
- NO_DEFAULT_ARGUMENT =
The null object used in #argument to signify that there are no default arguments
nil cannot be used as ‘nil’ is a valid default as well
Object.new
Instance Method Summary collapse
- #argument(argument_name, options) ⇒ Object
-
#arguments ⇒ Array<String>
The list of arguments required by this task model.
-
#default_argument(argname) ⇒ (Boolean,Object)
Access an argument’s default value.
-
#fullfills?(models) ⇒ Boolean
Checks if this model fullfills everything in
models
. -
#meaningful_arguments(arguments) ⇒ Object
The part of
arguments
that is meaningful for this task model.
Instance Method Details
#argument(argument_name, options) ⇒ Object
30 |
# File 'lib/roby/models/arguments.rb', line 30 inherited_attribute("argument", "__arguments", map: true) { {} } |
#arguments ⇒ Array<String>
Returns the list of arguments required by this task model.
33 34 35 |
# File 'lib/roby/models/arguments.rb', line 33 def arguments each_argument.map { |name, _| name } end |
#default_argument(argname) ⇒ (Boolean,Object)
Access an argument’s default value
91 92 93 94 95 |
# File 'lib/roby/models/arguments.rb', line 91 def default_argument(argname) if (arg = find_argument(argname)) && arg.has_default? [true, arg.default] end end |
#fullfills?(models) ⇒ Boolean
Checks if this model fullfills everything in models
110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/roby/models/arguments.rb', line 110 def fullfills?(models) unless models.respond_to?(:each) models = [models] end for tag in models unless has_ancestor?(tag) return false end end true end |
#meaningful_arguments(arguments) ⇒ Object
The part of arguments
that is meaningful for this task model
98 99 100 101 102 103 104 105 106 107 |
# File 'lib/roby/models/arguments.rb', line 98 def meaningful_arguments(arguments) self_arguments = self.arguments result = {} arguments.each_assigned_argument do |key, value| if self_arguments.include?(key) result[key] = value end end result end |