Class: Pwwka::PublishOptions
- Inherits:
-
Object
- Object
- Pwwka::PublishOptions
- Defined in:
- lib/pwwka/publish_options.rb
Overview
Encaspulates the options we pass to ‘topic_exchange.publish` as well as the various defaults and auto-generated values.
Instance Method Summary collapse
-
#initialize(routing_key:, message_id: :auto_generate, type:, headers:, expiration: nil) ⇒ PublishOptions
constructor
A new instance of PublishOptions.
- #message_id ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(routing_key:, message_id: :auto_generate, type:, headers:, expiration: nil) ⇒ PublishOptions
Returns a new instance of PublishOptions.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pwwka/publish_options.rb', line 6 def initialize(routing_key: , message_id: :auto_generate, type: , headers:, expiration: nil) = { routing_key: routing_key, message_id: .to_s == "auto_generate" ? SecureRandom.uuid : , content_type: "application/json; version=1", persistent: true, app_id: Pwwka.configuration.app_id } [:type] = type unless type.nil? [:headers] = headers unless headers.nil? [:expiration] = expiration unless expiration.nil? end |
Instance Method Details
#message_id ⇒ Object
23 24 25 |
# File 'lib/pwwka/publish_options.rb', line 23 def [:message_id] end |
#to_h ⇒ Object
26 27 28 |
# File 'lib/pwwka/publish_options.rb', line 26 def to_h .merge(timestamp: Time.now.to_i) end |