Class: Bunny::GetResponse
- Inherits:
-
Object
- Object
- Bunny::GetResponse
- Includes:
- Enumerable
- Defined in:
- lib/bunny/get_response.rb
Overview
Wraps AMQ::Protocol::Basic::GetOk to provide access to the delivery properties as immutable hash as well as methods.
Instance Attribute Summary collapse
-
#channel ⇒ Bunny::Channel
readonly
Channel this basic.get-ok response is on.
Instance Method Summary collapse
-
#[](k) ⇒ Object
Accesses delivery properties by key.
-
#delivery_tag ⇒ String
Delivery identifier that is used to acknowledge, reject and nack deliveries.
-
#each(*args, &block) ⇒ Object
Iterates over the delivery properties.
-
#exchange ⇒ String
Name of the exchange this message was published to.
-
#initialize(get_ok, channel) ⇒ GetResponse
constructor
A new instance of GetResponse.
- #inspect ⇒ Object
-
#redelivered ⇒ Boolean
(also: #redelivered?)
True if this delivery is a redelivery (the message was requeued at least once).
-
#routing_key ⇒ String
Routing key this message was published with.
-
#to_hash ⇒ Hash
Hash representation of this delivery info.
- #to_s ⇒ Object
Constructor Details
#initialize(get_ok, channel) ⇒ GetResponse
Returns a new instance of GetResponse.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bunny/get_response.rb', line 23 def initialize(get_ok, channel) @get_ok = get_ok @hash = { :delivery_tag => @get_ok.delivery_tag, :redelivered => @get_ok.redelivered, :exchange => @get_ok.exchange, :routing_key => @get_ok.routing_key, :channel => channel } @channel = channel end |
Instance Attribute Details
#channel ⇒ Bunny::Channel (readonly)
Returns Channel this basic.get-ok response is on.
20 21 22 |
# File 'lib/bunny/get_response.rb', line 20 def channel @channel end |
Instance Method Details
#[](k) ⇒ Object
Accesses delivery properties by key
43 44 45 |
# File 'lib/bunny/get_response.rb', line 43 def [](k) @hash[k] end |
#delivery_tag ⇒ String
Returns Delivery identifier that is used to acknowledge, reject and nack deliveries.
63 64 65 |
# File 'lib/bunny/get_response.rb', line 63 def delivery_tag @get_ok.delivery_tag end |
#each(*args, &block) ⇒ Object
Iterates over the delivery properties
37 38 39 |
# File 'lib/bunny/get_response.rb', line 37 def each(*args, &block) @hash.each(*args, &block) end |
#exchange ⇒ String
Returns Name of the exchange this message was published to.
74 75 76 |
# File 'lib/bunny/get_response.rb', line 74 def exchange @get_ok.exchange end |
#inspect ⇒ Object
58 59 60 |
# File 'lib/bunny/get_response.rb', line 58 def inspect to_hash.inspect end |
#redelivered ⇒ Boolean Also known as: redelivered?
Returns true if this delivery is a redelivery (the message was requeued at least once).
68 69 70 |
# File 'lib/bunny/get_response.rb', line 68 def redelivered @get_ok.redelivered end |
#routing_key ⇒ String
Returns Routing key this message was published with.
79 80 81 |
# File 'lib/bunny/get_response.rb', line 79 def routing_key @get_ok.routing_key end |
#to_hash ⇒ Hash
Returns Hash representation of this delivery info.
48 49 50 |
# File 'lib/bunny/get_response.rb', line 48 def to_hash @hash end |
#to_s ⇒ Object
53 54 55 |
# File 'lib/bunny/get_response.rb', line 53 def to_s to_hash.to_s end |