Class: Taskr::Actions::Base
- Inherits:
-
Object
- Object
- Taskr::Actions::Base
- Includes:
- OpenWFE::Schedulable
- Defined in:
- lib/taskr/actions.rb
Overview
The base class for all Actions. Extend this to define your own custom Action.
Direct Known Subclasses
Rest, Ruby, Shell, Taskr4rails
Instance Attribute Summary collapse
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#task ⇒ Object
Returns the value of attribute task.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(parameters) ⇒ Base
constructor
A new instance of Base.
- #trigger(trigger_args = {}) ⇒ Object
Constructor Details
#initialize(parameters) ⇒ Base
Returns a new instance of Base.
50 51 52 |
# File 'lib/taskr/actions.rb', line 50 def initialize(parameters) self.parameters = HashWithIndifferentAccess.new(parameters) end |
Instance Attribute Details
#parameters ⇒ Object
Returns the value of attribute parameters.
47 48 49 |
# File 'lib/taskr/actions.rb', line 47 def parameters @parameters end |
#task ⇒ Object
Returns the value of attribute task.
48 49 50 |
# File 'lib/taskr/actions.rb', line 48 def task @task end |
Instance Method Details
#execute ⇒ Object
54 55 56 |
# File 'lib/taskr/actions.rb', line 54 def execute raise NotImplementedError, "Implement me!" end |
#trigger(trigger_args = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/taskr/actions.rb', line 58 def trigger(trigger_args = {}) begin $LOG.info("Executing task #{self.task.name}") execute task.update_attribute(:last_triggered, Time.now) task.update_attribute(:last_triggered_error, nil) rescue => e puts $LOG.error(e) $LOG.debug(e.backtrace.join($/)) details = e. details += "\n\n#{$LAST_ERROR_BODY}" if $LAST_ERROR_BODY # dumb way of reading Restr errors... Restr needs to be fixed task.update_attribute(:last_triggered, Time.now) task.update_attribute(:last_triggered_error, {:type => e.class.to_s, :message => details}) raise e end end |