Sha256: f6658501578ccee43c5288c69b836a1b1700286235d34d3722742109e655531a

Contents?: true

Size: 671 Bytes

Versions: 7

Compression:

Stored size: 671 Bytes

Contents

class Mercury
  class ReceivedMessage
    attr_reader :content, :metadata

    def initialize(content, metadata, is_ackable: false)
      @content = content
      @metadata = metadata
      @is_ackable = is_ackable
    end

    def tag
      metadata.routing_key
    end

    def headers
      metadata.headers || {}
    end

    def ack
      @is_ackable or raise 'This message is not ackable'
      metadata.ack
    end

    def reject
      @is_ackable or raise 'This message is not rejectable'
      metadata.reject(requeue: false)
    end

    def nack
      @is_ackable or raise 'This message is not nackable'
      metadata.reject(requeue: true)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mercury_amqp-0.2.0 lib/mercury/received_message.rb
mercury_amqp-0.1.9 lib/mercury/received_message.rb
mercury_amqp-0.1.7 lib/mercury/received_message.rb
mercury_amqp-0.1.6 lib/mercury/received_message.rb
mercury_amqp-0.1.5 lib/mercury/received_message.rb
mercury_amqp-0.1.4 lib/mercury/received_message.rb
mercury_amqp-0.1.3 lib/mercury/received_message.rb