Class: Henry::Task::DummyTask

Inherits:
Henry::Task show all
Defined in:
lib/henry/task/dummy_task.rb

Instance Method Summary collapse

Instance Method Details

#configure(params, extended_context = {}) ⇒ Object

Configures the Task.

Parameters:

  • params (Hash)

    the task params.

  • extended_context (Hash) (defaults to: {})

    task extended context.



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

#executeObject

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.message ||= 'OK'
  self.execution.log ||= []
  self.execution.output ||= 'OK'
rescue Exception => e
  self.execution.code ||= 'ERROR'
  self.execution.message ||= e.message
  self.execution.log ||= []
  self.execution.backtrace ||= e.backtrace
  self.execution.output ||= 'ERROR'
end