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: Job, 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_job_task(process, job, args, options = {}) ⇒ 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.
-
#on_failed_entry(*args) ⇒ Object
callback for when the task has failed.
-
#paused? ⇒ Boolean
helper method, delegating to process.
- #queue ⇒ Object
- #to_s ⇒ Object
Methods included from Persistence
add_process_to_list, included, list_key
Constructor Details
Instance Attribute Details
#next ⇒ Object
the next task in the sequence
29 30 31 |
# File 'lib/taskinator/task.rb', line 29 def next @next end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
26 27 28 |
# File 'lib/taskinator/task.rb', line 26 def @options end |
#process ⇒ Object (readonly)
Returns the value of attribute process.
24 25 26 |
# File 'lib/taskinator/task.rb', line 24 def process @process end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
25 26 27 |
# File 'lib/taskinator/task.rb', line 25 def uuid @uuid end |
Class Method Details
.base_key ⇒ Object
19 20 21 |
# File 'lib/taskinator/task.rb', line 19 def base_key 'task' end |
.define_job_task(process, job, args, options = {}) ⇒ Object
11 12 13 |
# File 'lib/taskinator/task.rb', line 11 def define_job_task(process, job, args, ={}) Job.new(process, job, args, ) 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
15 16 17 |
# File 'lib/taskinator/task.rb', line 15 def define_sub_process_task(process, sub_process, ={}) SubProcess.new(process, sub_process, ) end |
Instance Method Details
#<=>(other) ⇒ Object
46 47 48 |
# File 'lib/taskinator/task.rb', line 46 def <=>(other) uuid <=> other.uuid end |
#accept(visitor) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/taskinator/task.rb', line 39 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
93 94 95 96 |
# File 'lib/taskinator/task.rb', line 93 def can_complete_task?(*args) # subclasses must implement this method raise NotImplementedError end |
#cancelled? ⇒ Boolean
helper method, delegating to process
125 126 127 |
# File 'lib/taskinator/task.rb', line 125 def cancelled? process.cancelled? end |
#enqueue ⇒ Object
103 104 105 |
# File 'lib/taskinator/task.rb', line 103 def enqueue Taskinator.queue.enqueue_task(self) end |
#on_completed_entry(*args) ⇒ Object
callback for when the task has completed
108 109 110 111 |
# File 'lib/taskinator/task.rb', line 108 def on_completed_entry(*args) # notify the process that this task has completed process.task_completed(self) end |
#on_failed_entry(*args) ⇒ Object
callback for when the task has failed
114 115 116 117 |
# File 'lib/taskinator/task.rb', line 114 def on_failed_entry(*args) # notify the process that this task has failed process.task_failed(self, args.last) end |
#paused? ⇒ Boolean
helper method, delegating to process
120 121 122 |
# File 'lib/taskinator/task.rb', line 120 def paused? process.paused? end |
#queue ⇒ Object
54 55 56 |
# File 'lib/taskinator/task.rb', line 54 def queue [:queue] end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/taskinator/task.rb', line 50 def to_s "#<#{self.class.name}:#{uuid}>" end |