Class: Minion::Handler
- Inherits:
-
Object
- Object
- Minion::Handler
- Defined in:
- lib/mb-minion/handler.rb
Instance Attribute Summary collapse
-
#batch_size ⇒ Object
readonly
Returns the value of attribute batch_size.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#queue_name ⇒ Object
readonly
Returns the value of attribute queue_name.
-
#wait ⇒ Object
readonly
Returns the value of attribute wait.
Instance Method Summary collapse
-
#execute ⇒ Object
Executes the handler.
-
#initialize(queue_name, block, options = {}) ⇒ Handler
constructor
Instantiate the new handler.
Constructor Details
#initialize(queue_name, block, options = {}) ⇒ Handler
Instantiate the new handler. Takes a queue name and optional lambda to determine conditionally if a queue is subscribable.
27 28 29 30 31 32 33 |
# File 'lib/mb-minion/handler.rb', line 27 def initialize(queue_name, block, = {}) @queue_name, @block = queue_name, block @subscribable = [:when] @batch_size = [:batch_size] @wait = [:wait] || false raise ArgumentError, "wait parameter makes no sense without a batch_size" if (@wait && ! @batch_size) end |
Instance Attribute Details
#batch_size ⇒ Object (readonly)
Returns the value of attribute batch_size.
5 6 7 |
# File 'lib/mb-minion/handler.rb', line 5 def batch_size @batch_size end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
5 6 7 |
# File 'lib/mb-minion/handler.rb', line 5 def block @block end |
#queue_name ⇒ Object (readonly)
Returns the value of attribute queue_name.
5 6 7 |
# File 'lib/mb-minion/handler.rb', line 5 def queue_name @queue_name end |
#wait ⇒ Object (readonly)
Returns the value of attribute wait.
5 6 7 |
# File 'lib/mb-minion/handler.rb', line 5 def wait @wait end |
Instance Method Details
#execute ⇒ Object
Executes the handler. Will subscribe to a queue or unsubscribe to it depending on the conditions.
12 13 14 |
# File 'lib/mb-minion/handler.rb', line 12 def execute subscribable? ? subscribe : unsubscribe end |