Class: Taskinator::Task
- Inherits:
-
Object
- Object
- Taskinator::Task
- Includes:
- Comparable, Persistence, Workflow
- Defined in:
- lib/taskinator/task.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Step, SubProcess
Instance Attribute Summary collapse
-
#next ⇒ Object
the next task in the sequence.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#process ⇒ Object
readonly
Returns the value of attribute process.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Class Method Summary collapse
- .base_key ⇒ Object
- .define_step_task(process, method, args, options = {}) ⇒ Object
- .define_sub_process_task(process, sub_process, options = {}) ⇒ Object
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #accept(visitor) ⇒ Object
- #can_complete_task?(*args) ⇒ Boolean
-
#cancelled? ⇒ Boolean
helper method, delegating to process.
- #enqueue ⇒ Object
-
#initialize(process, options = {}) ⇒ Task
constructor
A new instance of Task.
-
#on_completed_entry(*args) ⇒ Object
callback for when the task has completed.
-
#paused? ⇒ Boolean
helper method, delegating to process.
- #to_s ⇒ Object
Methods included from Persistence
Constructor Details
Instance Attribute Details
#next ⇒ Object
the next task in the sequence
25 26 27 |
# File 'lib/taskinator/task.rb', line 25 def next @next end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
22 23 24 |
# File 'lib/taskinator/task.rb', line 22 def @options end |
#process ⇒ Object (readonly)
Returns the value of attribute process.
20 21 22 |
# File 'lib/taskinator/task.rb', line 20 def process @process end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
21 22 23 |
# File 'lib/taskinator/task.rb', line 21 def uuid @uuid end |
Class Method Details
.base_key ⇒ Object
15 16 17 |
# File 'lib/taskinator/task.rb', line 15 def base_key 'task' end |
.define_step_task(process, method, args, options = {}) ⇒ Object
7 8 9 |
# File 'lib/taskinator/task.rb', line 7 def define_step_task(process, method, args, ={}) Step.new(process, method, args, ) end |
.define_sub_process_task(process, sub_process, options = {}) ⇒ Object
11 12 13 |
# File 'lib/taskinator/task.rb', line 11 def define_sub_process_task(process, sub_process, ={}) SubProcess.new(process, sub_process, ) end |
Instance Method Details
#<=>(other) ⇒ Object
42 43 44 |
# File 'lib/taskinator/task.rb', line 42 def <=>(other) uuid <=> other.uuid end |
#accept(visitor) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/taskinator/task.rb', line 35 def accept(visitor) visitor.visit_attribute(:uuid) visitor.visit_process_reference(:process) visitor.visit_task_reference(:next) visitor.visit_args(:options) end |
#can_complete_task?(*args) ⇒ Boolean
78 79 80 81 |
# File 'lib/taskinator/task.rb', line 78 def can_complete_task?(*args) # subclasses must implement this method raise NotImplementedError end |
#cancelled? ⇒ Boolean
helper method, delegating to process
104 105 106 |
# File 'lib/taskinator/task.rb', line 104 def cancelled? process.cancelled? end |
#enqueue ⇒ Object
88 89 90 |
# File 'lib/taskinator/task.rb', line 88 def enqueue Taskinator.queue.enqueue_task(self) end |
#on_completed_entry(*args) ⇒ Object
callback for when the task has completed
93 94 95 96 |
# File 'lib/taskinator/task.rb', line 93 def on_completed_entry(*args) # notify the process that this task has completed process.task_completed(self) end |
#paused? ⇒ Boolean
helper method, delegating to process
99 100 101 |
# File 'lib/taskinator/task.rb', line 99 def paused? process.paused? end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/taskinator/task.rb', line 46 def to_s "#<#{self.class.name}:#{uuid}>" end |