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.



18
19
20
# File 'lib/dispatch-rider/dispatcher.rb', line 18

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

Instance Attribute Details

#handler_registrarObject (readonly)

Returns the value of attribute handler_registrar.



14
15
16
# File 'lib/dispatch-rider/dispatcher.rb', line 14

def handler_registrar
  @handler_registrar
end

Instance Method Details

#dispatch(message) ⇒ Object



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

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