module QueueingRabbit::Callbacks

Public Instance Methods

after_consuming(&block) click to toggle source
# File lib/queueing_rabbit/callbacks.rb, line 9
def after_consuming(&block)
  setup_callback(:consuming_done, &block)
end
before_consuming(&block) click to toggle source
# File lib/queueing_rabbit/callbacks.rb, line 5
def before_consuming(&block)
  setup_callback(:worker_ready, &block)
end
on_consumer_error(&block) click to toggle source
# File lib/queueing_rabbit/callbacks.rb, line 13
def on_consumer_error(&block)
  setup_callback(:consumer_error, &block)
end
on_event_machine_start(&block) click to toggle source
# 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) click to toggle source
# File lib/queueing_rabbit/callbacks.rb, line 21
def setup_callback(event, &block)
  @callbacks ||= {}
  @callbacks[event] ||= []
  @callbacks[event] << block
end
trigger_event(event, *args) click to toggle source
# 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