Method: Rap::Task#process
- Defined in:
- lib/rap/task.rb
#process(*inputs) ⇒ Object
Collects the inputs into an OpenStruct according to the class arg_names, and calls each class action in turn. This behavior echoes the behavior of Rake tasks.
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/rap/task.rb', line 275 def process(*inputs) # collect inputs to make a rakish-args object args = {} self.class.arg_names.each do |arg_name| break if inputs.empty? args[arg_name] = inputs.shift end args = OpenStruct.new(args) # execute each block assciated with this task self.class.actions.each do |action| case action.arity when 0 then action.call() when 1 then action.call(self) else action.call(self, args) end end nil end |