Class: Warren::Handler::Broadcast::Channel
- Inherits:
-
Object
- Object
- Warren::Handler::Broadcast::Channel
- Extended by:
- Forwardable
- Defined in:
- lib/warren/handler/broadcast.rb
Overview
Wraps a Bunny::Channel
Instance Attribute Summary collapse
-
#routing_key_prefix ⇒ Object
readonly
Returns the value of attribute routing_key_prefix.
Instance Method Summary collapse
-
#<<(message) ⇒ Warren::Handler::Broadcast::Channel
Publishes ‘message` to the configured exchange.
-
#initialize(bun_channel, routing_key_prefix:, exchange: nil) ⇒ Channel
constructor
A new instance of Channel.
-
#publish(message, exchange: configured_exchange) ⇒ Warren::Handler::Broadcast::Channel
Publishes ‘message` to `exchange` (Defaults to configured exchange).
Constructor Details
#initialize(bun_channel, routing_key_prefix:, exchange: nil) ⇒ Channel
Returns a new instance of Channel.
24 25 26 27 28 29 |
# File 'lib/warren/handler/broadcast.rb', line 24 def initialize(bun_channel, routing_key_prefix:, exchange: nil) @bun_channel = bun_channel @exchange_name = exchange @routing_key_prefix = routing_key_prefix @routing_key_template = Handler.routing_key_template(routing_key_prefix) end |
Instance Attribute Details
#routing_key_prefix ⇒ Object (readonly)
Returns the value of attribute routing_key_prefix.
20 21 22 |
# File 'lib/warren/handler/broadcast.rb', line 20 def routing_key_prefix @routing_key_prefix end |
Instance Method Details
#<<(message) ⇒ Warren::Handler::Broadcast::Channel
Publishes ‘message` to the configured exchange
38 39 40 |
# File 'lib/warren/handler/broadcast.rb', line 38 def <<() publish() end |
#publish(message, exchange: configured_exchange) ⇒ Warren::Handler::Broadcast::Channel
Publishes ‘message` to `exchange` (Defaults to configured exchange)
50 51 52 53 |
# File 'lib/warren/handler/broadcast.rb', line 50 def publish(, exchange: configured_exchange) exchange.publish(.payload, routing_key: key_for(), headers: .headers) self end |