Class: Stepladder::Worker
- Inherits:
-
Object
- Object
- Stepladder::Worker
- Defined in:
- lib/stepladder/worker.rb
Instance Attribute Summary collapse
-
#supplier ⇒ Object
Returns the value of attribute supplier.
Instance Method Summary collapse
-
#initialize(p = {}, &block) ⇒ Worker
constructor
A new instance of Worker.
- #product ⇒ Object
- #ready_to_work? ⇒ Boolean
- #|(subscribing_worker) ⇒ Object
Constructor Details
#initialize(p = {}, &block) ⇒ Worker
Returns a new instance of Worker.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/stepladder/worker.rb', line 5 def initialize(p={}, &block) @supplier = p[:supplier] @filter = p[:filter] || default_filter @task = block || p[:task] # don't define default task here # because we want to allow for # an initialized worker to have # a task injected, including # method-based tasks. end |
Instance Attribute Details
#supplier ⇒ Object
Returns the value of attribute supplier.
3 4 5 |
# File 'lib/stepladder/worker.rb', line 3 def supplier @supplier end |
Instance Method Details
#product ⇒ Object
16 17 18 19 |
# File 'lib/stepladder/worker.rb', line 16 def product ensure_ready_to_work! workflow.resume end |
#ready_to_work? ⇒ Boolean
21 22 23 |
# File 'lib/stepladder/worker.rb', line 21 def ready_to_work? @task && (supplier || !task_accepts_a_value?) end |
#|(subscribing_worker) ⇒ Object
25 26 27 28 |
# File 'lib/stepladder/worker.rb', line 25 def |(subscribing_worker) subscribing_worker.supplier = self subscribing_worker end |