Sha256: 2eb61d7bd4bb837840279de13eb25c94e48e3468fd2ef5675bd778c16dfd63c8

Contents?: true

Size: 1.17 KB

Versions: 9

Compression:

Stored size: 1.17 KB

Contents

module Bunny
  # Wraps AMQ::Protocol::Basic::Deliver to
  # provide access to the delivery properties as immutable hash as
  # well as methods.
  class DeliveryInfo

    #
    # Behaviors
    #

    include Enumerable

    #
    # API
    #

    def initialize(basic_deliver)
      @basic_deliver = basic_deliver
      @hash          = {
        :consumer_tag => basic_deliver.consumer_tag,
        :delivery_tag => basic_deliver.delivery_tag,
        :redelivered  => basic_deliver.redelivered,
        :exchange     => basic_deliver.exchange,
        :routing_key  => basic_deliver.routing_key
      }
    end

    def each(*args, &block)
      @hash.each(*args, &block)
    end

    def [](k)
      @hash[k]
    end

    def to_hash
      @hash
    end

    def to_s
      to_hash.to_s
    end

    def inspect
      to_hash.inspect
    end

    def consumer_tag
      @basic_deliver.consumer_tag
    end

    def delivery_tag
      @basic_deliver.delivery_tag
    end

    def redelivered
      @basic_deliver.redelivered
    end
    alias redelivered? redelivered

    def exchange
      @basic_deliver.exchange
    end

    def routing_key
      @basic_deliver.routing_key
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bunny-0.9.0.pre12 lib/bunny/delivery_info.rb
bunny-0.9.0.pre11 lib/bunny/delivery_info.rb
bunny-0.9.0.pre10 lib/bunny/delivery_info.rb
bunny-0.9.0.pre9 lib/bunny/delivery_info.rb
bunny-0.9.0.pre8 lib/bunny/delivery_info.rb
bunny-0.9.0.pre7 lib/bunny/delivery_info.rb
bunny-0.9.0.pre6 lib/bunny/delivery_info.rb
bunny-0.9.0.pre5 lib/bunny/delivery_info.rb
bunny-0.9.0.pre4 lib/bunny/delivery_info.rb