Class: Henry::Task::DummyTask
- Inherits:
-
Henry::Task
- Object
- Henry::Task
- Henry::Task::DummyTask
- Defined in:
- lib/henry/task/dummy_task.rb
Instance Method Summary collapse
-
#configure(params, extended_context = {}) ⇒ Object
Configures the Task.
-
#execute ⇒ Object
Process the params and seets the execution params based on them.
Instance Method Details
#configure(params, extended_context = {}) ⇒ Object
Configures the Task.
11 12 13 14 15 16 17 18 |
# File 'lib/henry/task/dummy_task.rb', line 11 def configure(params, extended_context={}) @actions = (params['actions'] || []).collect do |action| OpenStruct.new({ command: action['type'].downcase.to_sym, params: action['arguments'] }) end end |
#execute ⇒ Object
Process the params and seets the execution params based on them.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/henry/task/dummy_task.rb', line 21 def execute abort 'You must configure the task before execution.' if @actions.nil? dummy = Henry::Dummy.new(self) @actions.each do |action| dummy.send(action.command, *action.params) end self.execution.code ||= 'OK' self.execution. ||= 'OK' self.execution.log ||= [] self.execution.output ||= 'OK' rescue Exception => e self.execution.code ||= 'ERROR' self.execution. ||= e. self.execution.log ||= [] self.execution.backtrace ||= e.backtrace self.execution.output ||= 'ERROR' end |