Class: Pheromone::Messaging::MessageDispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/pheromone/messaging/message_dispatcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(message_parameters:, dispatch_method:) ⇒ MessageDispatcher

Returns a new instance of MessageDispatcher.



12
13
14
15
# File 'lib/pheromone/messaging/message_dispatcher.rb', line 12

def initialize(message_parameters:, dispatch_method:)
  @message_parameters = message_parameters
  @dispatch_method = dispatch_method
end

Instance Method Details

#dispatchObject



17
18
19
20
21
22
23
24
# File 'lib/pheromone/messaging/message_dispatcher.rb', line 17

def dispatch
  return unless Pheromone.enabled?
  if @dispatch_method == :sync
    message.send!
  elsif @dispatch_method == :async
    send_message_asynchronously
  end
end