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.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bunny/get_response.rb', line 25 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.
22 23 24 |
# File 'lib/bunny/get_response.rb', line 22 def channel @channel end |
Instance Method Details
#[](k) ⇒ Object
Accesses delivery properties by key
45 46 47 |
# File 'lib/bunny/get_response.rb', line 45 def [](k) @hash[k] end |
#delivery_tag ⇒ String
Returns Delivery identifier that is used to acknowledge, reject and nack deliveries.
65 66 67 |
# File 'lib/bunny/get_response.rb', line 65 def delivery_tag @get_ok.delivery_tag end |
#each(*args, &block) ⇒ Object
Iterates over the delivery properties
39 40 41 |
# File 'lib/bunny/get_response.rb', line 39 def each(*args, &block) @hash.each(*args, &block) end |
#exchange ⇒ String
Returns Name of the exchange this message was published to.
76 77 78 |
# File 'lib/bunny/get_response.rb', line 76 def exchange @get_ok.exchange end |
#inspect ⇒ Object
60 61 62 |
# File 'lib/bunny/get_response.rb', line 60 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).
70 71 72 |
# File 'lib/bunny/get_response.rb', line 70 def redelivered @get_ok.redelivered end |
#routing_key ⇒ String
Returns Routing key this message was published with.
81 82 83 |
# File 'lib/bunny/get_response.rb', line 81 def routing_key @get_ok.routing_key end |
#to_hash ⇒ Hash
Returns Hash representation of this delivery info.
50 51 52 |
# File 'lib/bunny/get_response.rb', line 50 def to_hash @hash end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/bunny/get_response.rb', line 55 def to_s to_hash.to_s end |