Class: Taskinator::Task
- Inherits:
-
Object
- Object
- Taskinator::Task
- Includes:
- Comparable, Persistence, Workflow
- Defined in:
- lib/taskinator/task.rb
Defined Under Namespace
Classes: Step, SubProcess
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#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(name, process, method, args, options = {}) ⇒ Object
- .define_sub_process_task(name, process, sub_process, options = {}) ⇒ Object
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #accept(visitor) ⇒ Object
- #can_complete_task? ⇒ Boolean
-
#cancelled? ⇒ Boolean
helper method, delegating to process.
- #enqueue ⇒ Object
-
#initialize(name, 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
#initialize(name, process, options = {}) ⇒ Task
Returns a new instance of Task.
28 29 30 31 32 33 34 35 |
# File 'lib/taskinator/task.rb', line 28 def initialize(name, process, ={}) raise ArgumentError, 'process' if process.nil? || !process.is_a?(Process) @uuid = SecureRandom.uuid @process = process @name = name = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
22 23 24 |
# File 'lib/taskinator/task.rb', line 22 def name @name end |
#next ⇒ Object
the next task in the sequence
26 27 28 |
# File 'lib/taskinator/task.rb', line 26 def next @next end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
23 24 25 |
# File 'lib/taskinator/task.rb', line 23 def 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(name, process, method, args, options = {}) ⇒ Object
7 8 9 |
# File 'lib/taskinator/task.rb', line 7 def define_step_task(name, process, method, args, ={}) Step.new(name, process, method, args, ) end |
.define_sub_process_task(name, process, sub_process, options = {}) ⇒ Object
11 12 13 |
# File 'lib/taskinator/task.rb', line 11 def define_sub_process_task(name, process, sub_process, ={}) SubProcess.new(name, process, sub_process, ) end |
Instance Method Details
#<=>(other) ⇒ Object
45 46 47 |
# File 'lib/taskinator/task.rb', line 45 def <=>(other) uuid <=> other.uuid end |
#accept(visitor) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/taskinator/task.rb', line 37 def accept(visitor) visitor.visit_attribute(:uuid) visitor.visit_process_reference(:process) visitor.visit_attribute(:name) visitor.visit_task_reference(:next) visitor.visit_args(:options) end |
#can_complete_task? ⇒ Boolean
81 82 83 84 |
# File 'lib/taskinator/task.rb', line 81 def can_complete_task? # subclasses must implement this method raise NotImplementedError end |
#cancelled? ⇒ Boolean
helper method, delegating to process
107 108 109 |
# File 'lib/taskinator/task.rb', line 107 def cancelled? process.cancelled? end |
#enqueue ⇒ Object
91 92 93 |
# File 'lib/taskinator/task.rb', line 91 def enqueue Taskinator.queue.enqueue_task(self) end |
#on_completed_entry(*args) ⇒ Object
callback for when the task has completed
96 97 98 99 |
# File 'lib/taskinator/task.rb', line 96 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
102 103 104 |
# File 'lib/taskinator/task.rb', line 102 def paused? process.paused? end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/taskinator/task.rb', line 49 def to_s "#<#{self.class.name}:#{uuid} @name=\"#{name}\">" end |