Class: Taskinator::Process::Concurrent
- Inherits:
-
Process
- Object
- Process
- Taskinator::Process::Concurrent
- Defined in:
- lib/taskinator/process.rb
Instance Attribute Summary collapse
-
#complete_on ⇒ Object
readonly
Returns the value of attribute complete_on.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
-
#initialize(name, definition, complete_on = CompleteOn::Default, options = {}) ⇒ Concurrent
constructor
A new instance of Concurrent.
- #start ⇒ Object
- #task_completed(task) ⇒ Object
- #tasks_completed?(*args) ⇒ Boolean
Constructor Details
#initialize(name, definition, complete_on = CompleteOn::Default, options = {}) ⇒ Concurrent
Returns a new instance of Concurrent.
145 146 147 148 |
# File 'lib/taskinator/process.rb', line 145 def initialize(name, definition, complete_on=CompleteOn::Default, ={}) super(name, definition, ) @complete_on = complete_on end |
Instance Attribute Details
#complete_on ⇒ Object (readonly)
Returns the value of attribute complete_on.
143 144 145 |
# File 'lib/taskinator/process.rb', line 143 def complete_on @complete_on end |
Instance Method Details
#accept(visitor) ⇒ Object
173 174 175 176 |
# File 'lib/taskinator/process.rb', line 173 def accept(visitor) super visitor.visit_attribute(:complete_on) end |
#start ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/taskinator/process.rb', line 150 def start if tasks.any? tasks.each(&:enqueue!) else complete! # weren't any tasks to start with end end |
#task_completed(task) ⇒ Object
158 159 160 161 162 |
# File 'lib/taskinator/process.rb', line 158 def task_completed(task) # when complete on first, then don't bother with subsequent tasks completing return if completed? complete! if can_complete? end |
#tasks_completed?(*args) ⇒ Boolean
164 165 166 167 168 169 170 171 |
# File 'lib/taskinator/process.rb', line 164 def tasks_completed?(*args) # TODO: optimize this if (complete_on == CompleteOn::First) tasks.any?(&:completed?) else tasks.all?(&:completed?) end end |