Class: Loco::Sender
- Inherits:
-
Object
- Object
- Loco::Sender
- Defined in:
- lib/loco/sender.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(recipients, payload) ⇒ Object
-
#initialize ⇒ Sender
constructor
A new instance of Sender.
Constructor Details
#initialize ⇒ Sender
Returns a new instance of Sender.
23 24 25 |
# File 'lib/loco/sender.rb', line 23 def initialize @uuids = [] end |
Class Method Details
.call(recipient_s, payload = {}) ⇒ Object
6 7 8 9 10 |
# File 'lib/loco/sender.rb', line 6 def call(recipient_s, payload = {}) payload = with_idempotency_key(payload) recipients = recipient_s.is_a?(Array) ? recipient_s : [recipient_s] new.(recipients, payload) end |
Instance Method Details
#call(recipients, payload) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/loco/sender.rb', line 27 def call(recipients, payload) recipients.each do |recipient| case recipient when String then broadcast_to(recipient, payload) when Hash then process_hash(recipient, payload) else find_and_broadcast_to(recipient, payload) end end payload[:loco][:idempotency_key] end |