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.



87
88
89
# File 'lib/taskr/actions.rb', line 87

def initialize
  self.actions = []
end

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



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

def actions
  @actions
end

#taskObject

Returns the value of attribute task.



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

def task
  @task
end

Instance Method Details

#trigger(trigger_args = {}) ⇒ Object



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

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