class RabbitmqClient::Callback
Callback
Object Store all plugins clallbacks Supported callback types are before and adter
Public Class Methods
new()
click to toggle source
# File lib/rabbitmq_client/callback.rb, line 14 def initialize @before = [] @after = [] end
Public Instance Methods
add(type, &callback)
click to toggle source
# File lib/rabbitmq_client/callback.rb, line 26 def add(type, &callback) case type when :before @before << callback when :after @after << callback else raise InvalidCallback, "Invalid callback type: #{type}" end end
execute(*args, &block)
click to toggle source
# File lib/rabbitmq_client/callback.rb, line 19 def execute(*args, &block) execute_before_callbacks(*args) result = block.call(*args) execute_after_callbacks(*args) result end
Private Instance Methods
execute_after_callbacks(*args)
click to toggle source
# File lib/rabbitmq_client/callback.rb, line 43 def execute_after_callbacks(*args) @after.each { |callback| callback.call(*args) } end
execute_before_callbacks(*args)
click to toggle source
# File lib/rabbitmq_client/callback.rb, line 39 def execute_before_callbacks(*args) @before.each { |callback| callback.call(*args) } end