Class: DispatchRider::Dispatcher

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Callbacks::Support
Defined in:
lib/dispatch-rider/dispatcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDispatcher

Returns a new instance of Dispatcher.



20
21
22
# File 'lib/dispatch-rider/dispatcher.rb', line 20

def initialize
  @handler_registrar = Registrars::Handler.new
end

Instance Attribute Details

#handler_registrarObject (readonly)

Returns the value of attribute handler_registrar.



16
17
18
# File 'lib/dispatch-rider/dispatcher.rb', line 16

def handler_registrar
  @handler_registrar
end

Instance Method Details

#dispatch(message) ⇒ Object



24
25
26
27
28
29
# File 'lib/dispatch-rider/dispatcher.rb', line 24

def dispatch(message)
  callbacks.invoke(:dispatch_message, message) do
    handler_registrar.fetch(message.subject).new.do_process(message)
  end
  true # success => true (delete message)
end