Sha256: f03862ca26ca07ce93b97eecaebe29e672c453b786c8da58e195a1d38b736ba7

Contents?: true

Size: 1.73 KB

Versions: 11

Compression:

Stored size: 1.73 KB

Contents

# encoding: utf-8

module AMQP
  # We keep this class around for sake of API compatibility with 0.7.x series.
  #
  # @note This class is not part of the public API and may be removed in the future without any warning.
  class Header

    #
    # API
    #

    # @return [AMQP::Channel]
    attr_reader :channel
    # AMQP method frame this header is associated with. Carries additional information that varies between AMQP methods.
    # @return [AMQ::Protocol::Method]
    attr_reader :method
    # AMQP message header as a hash
    # @return [Hash]
    attr_reader :header

    # @api public
    def initialize(channel, method, header)
      @channel, @method, @header = channel, method, header
    end

    # Acknowledges the receipt of this message with the server.
    # @param [Boolean] multiple Whether or not to acknowledge multiple messages
    # @api public
    def ack(multiple = false)
      @channel.acknowledge(@method.delivery_tag, multiple)
    end

    # Reject this message.
    # @option opts [Hash] :requeue (false) Whether message should be requeued.
    # @api public
    def reject(opts = {})
      @channel.reject(@method.delivery_tag, opts.fetch(:requeue, false))
    end

    # @return [Hash] AMQP message header w/o method-specific information.
    # @api public
    def to_hash
      @header
    end # to_hash

    def respond_to_missing?(meth, _)
      (@header && args.empty? && blk.nil? && @header.has_key?(meth)) || @method.respond_to?(meth)
    end

    # Returns AMQP message attributes.
    # @api public
    def method_missing(meth, *args, &blk)
      if @header && args.empty? && blk.nil? && @header.has_key?(meth)
        @header[meth]
      else
        @method.__send__(meth, *args, &blk)
      end
    end
  end # Header
end # AMQP

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
amqp-0.8.0.rc13 lib/amqp/header.rb
amqp-0.8.0.rc12 lib/amqp/header.rb
amqp-0.8.0.rc11 lib/amqp/header.rb
amqp-0.8.0.rc10 lib/amqp/header.rb
amqp-0.8.0.rc9 lib/amqp/header.rb
amqp-0.8.0.rc8 lib/amqp/header.rb
amqp-0.8.0.rc7 lib/amqp/header.rb
amqp-0.8.0.rc6 lib/amqp/header.rb
amqp-0.8.0.rc5 lib/amqp/header.rb
amqp-0.8.0.rc4 lib/amqp/header.rb
amqp-0.8.0.rc3 lib/amqp/header.rb