Class: Timberline::AnonymousWorker
- Defined in:
- lib/timberline/anonymous_worker.rb
Overview
The AnonymousWorker is exactly what it says on the tin - a way to process a queue without defining a new class, by instead just passing in a block that will be executed for each item on the queue as it’s popped.
Instance Method Summary collapse
-
#initialize(&block) ⇒ AnonymousWorker
constructor
Creates a new AnonymousWorker.
- #process_item(item) ⇒ Object
Methods inherited from Worker
#error_item, #executing_job?, #handle_process_exception, #keep_watching?, #retry_item, #watch
Constructor Details
#initialize(&block) ⇒ AnonymousWorker
Creates a new AnonymousWorker. The block’s binding will be updated to give it access to retry_item and error_item so that the block can easily control the processing flow for queued items.
21 22 23 24 |
# File 'lib/timberline/anonymous_worker.rb', line 21 def initialize(&block) @block = block fix_block_binding end |
Instance Method Details
#process_item(item) ⇒ Object
28 29 30 |
# File 'lib/timberline/anonymous_worker.rb', line 28 def process_item(item) @block.call(item, self) end |