lib/dispatch-rider/publisher/base.rb in dispatch-rider-1.2.11 vs lib/dispatch-rider/publisher/base.rb in dispatch-rider-1.3.0
- old
+ new
@@ -19,39 +19,49 @@
def publish(*args, &block)
raise NotImplementedError
end
+ private
+
+ def generate_new_message_id
+ if DispatchRider.config.debug
+ DispatchRider::Debug::PUBLISHER_MESSAGE_GUID
+ else
+ SecureRandom.uuid
+ end
+ end
+
end
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,
+ 'guid' => 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
@publisher || self.class.default_publisher
end
def destinations
self.class.instance_variable_get(:@destinations)
end
def subject
self.class.instance_variable_get(:@subject)
+ end
+
+ private
+
+ def generate_new_message_id
+ self.class.send(:generate_new_message_id)
end
end
end