lib/dispatch-rider/publisher.rb in dispatch-rider-2.0.0 vs lib/dispatch-rider/publisher.rb in dispatch-rider-2.1.0
- old
+ new
@@ -33,25 +33,19 @@
notification_service = notification_service_registrar.fetch(service)
notification_service.register(name, options)
self
end
- # @param [Hash] original_options should contain `:destinations` and `:message` keys
- def publish(original_options = {})
- options = build_publish_options(original_options)
-
- callbacks.invoke(:publish, options) do
+ def publish(message:, destinations:)
+ options = { message: build_message(message), destinations: destinations }
+ callbacks.invoke(:publish, **options) do
service_channel_mapper.map(options.delete(:destinations)).each do |(service, channels)|
- notification_service_registrar.fetch(service).publish(options.merge to: channels)
+ notification_service_registrar.fetch(service).publish(**(options.merge to: channels))
end
end
end
private
-
- def build_publish_options(message:, destinations:)
- { message: build_message(message), destinations: destinations }
- end
def build_message(attributes)
DispatchRider::Message.new(attributes).tap do |message|
message.body[:guid] ||= generate_new_message_id
end