Class: SWF::ActivityTaskHandler
- Inherits:
-
Object
- Object
- SWF::ActivityTaskHandler
- Extended by:
- TaskHandler
- Defined in:
- lib/swf/activity_task_handler.rb
Overview
subclass must call .register(), and define #handle(runner, task)
Constant Summary collapse
- @@handler_classes =
Set.new
Instance Attribute Summary collapse
-
#activity_task ⇒ Object
readonly
Returns the value of attribute activity_task.
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
Class Method Summary collapse
- .configuration_help_message ⇒ Object
- .fail!(task, args = {}) ⇒ Object
- .find_handler_class(task) ⇒ Object
- .handler_method_name(task) ⇒ Object
-
.register ⇒ Object
Register statically self (subclass) to handle activities.
Instance Method Summary collapse
- #activity_task_input ⇒ Object
- #call_handle ⇒ Object
-
#initialize(runner, task) ⇒ ActivityTaskHandler
constructor
A new instance of ActivityTaskHandler.
Methods included from TaskHandler
Constructor Details
#initialize(runner, task) ⇒ ActivityTaskHandler
Returns a new instance of ActivityTaskHandler.
13 14 15 16 |
# File 'lib/swf/activity_task_handler.rb', line 13 def initialize(runner, task) @runner = runner @activity_task = task end |
Instance Attribute Details
#activity_task ⇒ Object (readonly)
Returns the value of attribute activity_task.
12 13 14 |
# File 'lib/swf/activity_task_handler.rb', line 12 def activity_task @activity_task end |
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
12 13 14 |
# File 'lib/swf/activity_task_handler.rb', line 12 def runner @runner end |
Class Method Details
.configuration_help_message ⇒ Object
40 41 42 43 |
# File 'lib/swf/activity_task_handler.rb', line 40 def self. "Each activity task handler running on this task list in this domain must provide a handler class with a handle_* function for this activity_type's name.\n" + "I only have these classes: #{@@handler_classes.inspect}" end |
.fail!(task, args = {}) ⇒ Object
31 32 33 |
# File 'lib/swf/activity_task_handler.rb', line 31 def self.fail!(task, args={}) task.fail!(args) end |
.find_handler_class(task) ⇒ Object
35 36 37 38 |
# File 'lib/swf/activity_task_handler.rb', line 35 def self.find_handler_class(task) @@handler_classes.find {|x| x.instance_methods.include? handler_method_name task } # TODO: detect when two classes define the same named handle_* method ?!?! end |
.handler_method_name(task) ⇒ Object
45 46 47 |
# File 'lib/swf/activity_task_handler.rb', line 45 def self.handler_method_name(task) "handle_#{task.activity_type.name}".to_sym end |
.register ⇒ Object
Register statically self (subclass) to handle activities
27 28 29 |
# File 'lib/swf/activity_task_handler.rb', line 27 def self.register @@handler_classes << self end |
Instance Method Details
#activity_task_input ⇒ Object
22 23 24 |
# File 'lib/swf/activity_task_handler.rb', line 22 def activity_task_input JSON.parse(activity_task.input) end |
#call_handle ⇒ Object
18 19 20 |
# File 'lib/swf/activity_task_handler.rb', line 18 def call_handle send self.class.handler_method_name(activity_task) end |