Sha256: 36c26d1f5c5b7918f4153aab8179241764cb2c91f70d3595f4f224fec4922121

Contents?: true

Size: 1.5 KB

Versions: 126

Compression:

Stored size: 1.5 KB

Contents

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

    #
    # Behaviors
    #

    include Enumerable

    #
    # API
    #

    def initialize(basic_return)
      @basic_return = basic_return
      @hash          = {
        :reply_code   => basic_return.reply_code,
        :reply_text   => basic_return.reply_text,
        :exchange     => basic_return.exchange,
        :routing_key  => basic_return.routing_key
      }
    end

    # Iterates over the returned delivery properties
    # @see Enumerable#each
    def each(*args, &block)
      @hash.each(*args, &block)
    end

    # Accesses returned delivery properties by key
    # @see Hash#[]
    def [](k)
      @hash[k]
    end

    # @return [Hash] Hash representation of this returned delivery info
    def to_hash
      @hash
    end

    # @private
    def to_s
      to_hash.to_s
    end

    # @private
    def inspect
      to_hash.inspect
    end

    # @return [Integer] Reply (status) code of the cause
    def reply_code
      @basic_return.reply_code
    end

    # @return [Integer] Reply (status) text of the cause, explaining why the message was returned
    def reply_text
      @basic_return.reply_text
    end

    # @return [String] Exchange the message was published to
    def exchange
      @basic_return.exchange
    end

    # @return [String] Routing key the message has
    def routing_key
      @basic_return.routing_key
    end
  end
end

Version data entries

126 entries across 126 versions & 2 rubygems

Version Path
bunny-2.23.0 lib/bunny/return_info.rb
bunny-2.22.0 lib/bunny/return_info.rb
bunny-2.21.0 lib/bunny/return_info.rb
bunny-2.20.3 lib/bunny/return_info.rb
bunny-2.20.2 lib/bunny/return_info.rb
bunny-2.20.1 lib/bunny/return_info.rb
bunny-2.20.0 lib/bunny/return_info.rb
garaio_bunny-2.19.2 lib/bunny/return_info.rb
garaio_bunny-2.19.1 lib/bunny/return_info.rb
bunny-2.19.0 lib/bunny/return_info.rb
bunny-2.18.0 lib/bunny/return_info.rb
bunny-2.17.0 lib/bunny/return_info.rb
bunny-2.16.1 lib/bunny/return_info.rb
bunny-2.15.0 lib/bunny/return_info.rb
bunny-2.14.4 lib/bunny/return_info.rb
bunny-2.14.3 lib/bunny/return_info.rb
bunny-2.14.2 lib/bunny/return_info.rb
bunny-2.14.1 lib/bunny/return_info.rb
bunny-2.13.0 lib/bunny/return_info.rb
bunny-2.12.1 lib/bunny/return_info.rb