Class: RabbitmqClient::Callback
- Inherits:
-
Object
- Object
- RabbitmqClient::Callback
- 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
- #add(type, &callback) ⇒ Object
- #execute(*args, &block) ⇒ Object
-
#initialize ⇒ Callback
constructor
A new instance of Callback.
Constructor Details
#initialize ⇒ Callback
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 |