Class: RabbitmqClient::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/rabbitmq_client/callback.rb

Overview

Callback Object Store all plugins clallbacks Supported callback types are before and adter

Instance Method Summary collapse

Constructor Details

#initializeCallback

Returns a new instance of Callback.



14
15
16
17
# File 'lib/rabbitmq_client/callback.rb', line 14

def initialize
  @before = []
  @after = []
end

Instance Method Details

#add(type, &callback) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# 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) ⇒ Object



19
20
21
22
23
24
# 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