Class: Taskr::Actions::Multi

Inherits:
Object
  • Object
show all
Includes:
OpenWFE::Schedulable
Defined in:
lib/taskr/actions.rb

Overview

Do not extend this class. It is used internally to schedule multiple actions per task.

If you want to define your own custom Action, extend Taskr::Actions::Base

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMulti

Returns a new instance of Multi.



84
85
86
# File 'lib/taskr/actions.rb', line 84

def initialize
  self.actions = []
end

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



81
82
83
# File 'lib/taskr/actions.rb', line 81

def actions
  @actions
end

#taskObject

Returns the value of attribute task.



82
83
84
# File 'lib/taskr/actions.rb', line 82

def task
  @task
end

Instance Method Details

#trigger(trigger_args = {}) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/taskr/actions.rb', line 88

def trigger(trigger_args = {})
  begin
    $LOG.info("Executing task #{self.name}")
    actions.each do |a|
      a.execute
    end
    # TODO: maybe we should store last_triggered time on a per-action basis?
    task.update_attribute(:last_triggered, Time.now)
  rescue => e
    $LOG.error(e)
    $LOG.debug("#{e.stacktrace}")
    task.update_attribute(:last_triggered, Time.now)
    task.update_attribute(:last_triggered_error, e)
    raise e
  end
end