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. Hash representation is created lazily.
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.
-
#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.
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
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bunny/get_response.rb', line 36 def [](k) case k when :delivery_tag then @get_ok.delivery_tag when :redelivered then @get_ok.redelivered when :exchange then @get_ok.exchange when :routing_key then @get_ok.routing_key when :channel then @channel else nil end end |
#delivery_tag ⇒ String
Returns Delivery identifier that is used to acknowledge, reject and nack deliveries.
69 70 71 |
# File 'lib/bunny/get_response.rb', line 69 def delivery_tag @get_ok.delivery_tag end |
#each(*args, &block) ⇒ Object
Iterates over the delivery properties
30 31 32 |
# File 'lib/bunny/get_response.rb', line 30 def each(*args, &block) to_hash.each(*args, &block) end |
#exchange ⇒ String
Returns Name of the exchange this message was published to.
80 81 82 |
# File 'lib/bunny/get_response.rb', line 80 def exchange @get_ok.exchange end |
#redelivered ⇒ Boolean Also known as: redelivered?
Returns true if this delivery is a redelivery (the message was requeued at least once).
74 75 76 |
# File 'lib/bunny/get_response.rb', line 74 def redelivered @get_ok.redelivered end |
#routing_key ⇒ String
Returns Routing key this message was published with.
85 86 87 |
# File 'lib/bunny/get_response.rb', line 85 def routing_key @get_ok.routing_key end |
#to_hash ⇒ Hash
Returns Hash representation of this delivery info.
48 49 50 51 52 53 54 55 56 |
# File 'lib/bunny/get_response.rb', line 48 def to_hash @hash ||= { :delivery_tag => @get_ok.delivery_tag, :redelivered => @get_ok.redelivered, :exchange => @get_ok.exchange, :routing_key => @get_ok.routing_key, :channel => @channel } end |