Module: QueueingRabbit::Callbacks
- Included in:
- QueueingRabbit
- Defined in:
- lib/queueing_rabbit/callbacks.rb
Instance Method Summary collapse
- #after_consuming(&block) ⇒ Object
- #before_consuming(&block) ⇒ Object
- #on_consumer_error(&block) ⇒ Object
- #on_event_machine_start(&block) ⇒ Object
- #setup_callback(event, &block) ⇒ Object
- #trigger_event(event, *args) ⇒ Object
Instance Method Details
#after_consuming(&block) ⇒ Object
9 10 11 |
# File 'lib/queueing_rabbit/callbacks.rb', line 9 def after_consuming(&block) setup_callback(:consuming_done, &block) end |
#before_consuming(&block) ⇒ Object
5 6 7 |
# File 'lib/queueing_rabbit/callbacks.rb', line 5 def before_consuming(&block) setup_callback(:worker_ready, &block) end |
#on_consumer_error(&block) ⇒ Object
13 14 15 |
# File 'lib/queueing_rabbit/callbacks.rb', line 13 def on_consumer_error(&block) setup_callback(:consumer_error, &block) end |
#on_event_machine_start(&block) ⇒ Object
17 18 19 |
# File 'lib/queueing_rabbit/callbacks.rb', line 17 def on_event_machine_start(&block) setup_callback(:event_machine_started, &block) end |
#setup_callback(event, &block) ⇒ Object
21 22 23 24 25 |
# File 'lib/queueing_rabbit/callbacks.rb', line 21 def setup_callback(event, &block) @callbacks ||= {} @callbacks[event] ||= [] @callbacks[event] << block end |
#trigger_event(event, *args) ⇒ Object
27 28 29 30 31 |
# File 'lib/queueing_rabbit/callbacks.rb', line 27 def trigger_event(event, *args) if @callbacks && @callbacks[event] @callbacks[event].each { |c| c.call(*args) } end end |