class Bunny::DeliveryInfo
Wraps {AMQ::Protocol::Basic::Deliver} to provide access to the delivery properties as immutable hash as well as methods.
Attributes
@return [Bunny::Channel] Channel this delivery is on
@return [Bunny::Consumer] Consumer this delivery is for
Public Class Methods
@private
# File lib/bunny/delivery_info.rb, line 25 def initialize(basic_deliver, consumer, channel) @basic_deliver = basic_deliver @hash = { :consumer_tag => basic_deliver.consumer_tag, :delivery_tag => VersionedDeliveryTag.new(basic_deliver.delivery_tag, channel.recoveries_counter), :redelivered => basic_deliver.redelivered, :exchange => basic_deliver.exchange, :routing_key => basic_deliver.routing_key, :consumer => consumer, :channel => channel } @consumer = consumer @channel = channel end
Public Instance Methods
Accesses delivery properties by key @see Hash#[]
# File lib/bunny/delivery_info.rb, line 48 def [](k) @hash[k] end
@return [String] Consumer tag this delivery is for
# File lib/bunny/delivery_info.rb, line 68 def consumer_tag @basic_deliver.consumer_tag end
@return [String] Delivery identifier that is used to acknowledge, reject and nack deliveries
# File lib/bunny/delivery_info.rb, line 73 def delivery_tag @basic_deliver.delivery_tag end
Iterates over the delivery properties @see Enumerable#each
# File lib/bunny/delivery_info.rb, line 42 def each(*args, &block) @hash.each(*args, &block) end
@return [String] Name of the exchange this message was published to
# File lib/bunny/delivery_info.rb, line 84 def exchange @basic_deliver.exchange end
@private
# File lib/bunny/delivery_info.rb, line 63 def inspect to_hash.inspect end
@return [Boolean] true if this delivery is a redelivery (the message was requeued at least once)
# File lib/bunny/delivery_info.rb, line 78 def redelivered @basic_deliver.redelivered end
@return [String] Routing key this message was published with
# File lib/bunny/delivery_info.rb, line 89 def routing_key @basic_deliver.routing_key end
@return [Hash] Hash representation of this delivery info
# File lib/bunny/delivery_info.rb, line 53 def to_hash @hash end
@private
# File lib/bunny/delivery_info.rb, line 58 def to_s to_hash.to_s end