Class: Bunny::Exchange
- Inherits:
-
Object
- Object
- Bunny::Exchange
- Defined in:
- lib/stuffed_bunny/bunny_overrides.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(client, name, options = {}) ⇒ Exchange
constructor
A new instance of Exchange.
-
#publish(data, options = {}) ⇒ Object
To facilite testing this adds a Struct containing the data
message
and routingkey
to therouted_messages
. - #routed_messages ⇒ Object
Constructor Details
#initialize(client, name, options = {}) ⇒ Exchange
Returns a new instance of Exchange.
40 41 42 43 |
# File 'lib/stuffed_bunny/bunny_overrides.rb', line 40 def initialize(client, name, = {}) @client, @name = client, name @type = [:type] end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
38 39 40 |
# File 'lib/stuffed_bunny/bunny_overrides.rb', line 38 def client @client end |
#name ⇒ Object
Returns the value of attribute name.
38 39 40 |
# File 'lib/stuffed_bunny/bunny_overrides.rb', line 38 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
38 39 40 |
# File 'lib/stuffed_bunny/bunny_overrides.rb', line 38 def type @type end |
Instance Method Details
#publish(data, options = {}) ⇒ Object
To facilite testing this adds a Struct containing the data message
and routing key
to the routed_messages
.
Example usage: Bunny.run do |b|
topic = b.exchange("some_topic_name", SOME_EXCHANGE_OPTIONS)
= { :key => "some.routing.key" }.merge(SOME_PUBLISH_OPTIONS)
topic.publish("some message", )
end
Testing: … routed_message = @bunny.exchanges.routed_messages assert_equal “some message”, routed_message.message assert_equal “some.routing.key”, routed_message.key
64 65 66 |
# File 'lib/stuffed_bunny/bunny_overrides.rb', line 64 def publish(data, = {}) << Struct.new(:message, :key).new(data, [:key]) end |
#routed_messages ⇒ Object
45 46 47 |
# File 'lib/stuffed_bunny/bunny_overrides.rb', line 45 def @routed_messaged ||= [] end |