Class: Consumer::Dispatch
- Inherits:
-
Object
- Object
- Consumer::Dispatch
- Includes:
- Log::Dependency
- Defined in:
- lib/consumer/dispatch.rb,
lib/consumer/dispatch/substitute.rb
Defined Under Namespace
Modules: Substitute
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.build(handlers = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/consumer/dispatch.rb', line 11 def self.build(handlers=nil) handlers = Array(handlers) instance = new handlers.each do |handler| instance.add_handler(handler) end instance end |
Instance Method Details
#add_handler(handler) ⇒ Object
35 36 37 |
# File 'lib/consumer/dispatch.rb', line 35 def add_handler(handler) handlers << handler end |
#call(message_data) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/consumer/dispatch.rb', line 23 def call() logger.trace { "Dispatching event (#{LogText.()})" } handlers.each do |handle| handle.() end logger.debug { "Event dispatched (#{LogText.()}, Handlers Count: #{handlers.count})" } nil end |
#handlers ⇒ Object
5 6 7 |
# File 'lib/consumer/dispatch.rb', line 5 def handlers @handlers ||= [] end |
#to_proc ⇒ Object
39 40 41 |
# File 'lib/consumer/dispatch.rb', line 39 def to_proc method(:call) end |