lib/dispatch-rider/publisher/base.rb in dispatch-rider-1.2.10 vs lib/dispatch-rider/publisher/base.rb in dispatch-rider-1.2.11

- old
+ new

@@ -1,5 +1,7 @@ +require 'securerandom' + module DispatchRider class Publisher::Base class << self @@ -24,10 +26,18 @@ def initialize(publisher = nil) @publisher = publisher end def publish(body) + raise ArgumentError, 'body should be a hash' unless body.kind_of?(Hash) + body = body.merge({ + 'guid' => self.class.generate_new_message_id, + }) publisher.publish(destinations: destinations, message: { subject: subject, body: body }) + end + + def self.generate_new_message_id + SecureRandom.uuid end private def publisher