class BunnyMock::GetResponse

Attributes

channel[R]

@return [BunnyMock::Channel] Channel the response is from

queue[R]

@return [BunnyMock::Queue] Queue the response is from

Public Class Methods

new(channel, queue, opts = {}) click to toggle source

@private

# File lib/bunny_mock/get_response.rb, line 21
def initialize(channel, queue, opts = {})
  @channel = channel
  @queue = queue
  @hash = {
    delivery_tag: self.class.next_delivery_tag,
    redelivered:  false,
    exchange:     opts.fetch(:exchange, ''),
    routing_key:  opts.fetch(:routing_key, queue.name)
  }
end
next_delivery_tag() click to toggle source

@return [Integer] incrementing numerically value to support `#ack` with multiple=true

# File lib/bunny_mock/get_response.rb, line 81
def self.next_delivery_tag
  @delivery_tag ||= 0
  @delivery_tag += 1
end

Public Instance Methods

[](k) click to toggle source

Accesses delivery properties by key @see Hash#[]

# File lib/bunny_mock/get_response.rb, line 40
def [](k)
  @hash[k]
end
delivery_tag() click to toggle source

@return [String] Delivery identifier that is used to acknowledge, reject and nack deliveries

# File lib/bunny_mock/get_response.rb, line 60
def delivery_tag
  @hash[:delivery_tag]
end
each(*args, &block) click to toggle source

Iterates over the delivery properties @see Enumerable#each

# File lib/bunny_mock/get_response.rb, line 34
def each(*args, &block)
  @hash.each(*args, &block)
end
exchange() click to toggle source

@return [String] Name of the exchange this message was published to

# File lib/bunny_mock/get_response.rb, line 71
def exchange
  @hash[:exchange]
end
inspect() click to toggle source

@private

# File lib/bunny_mock/get_response.rb, line 55
def inspect
  to_hash.inspect
end
redelivered() click to toggle source

@return [Boolean] true if this delivery is a redelivery (the message was requeued at least once)

# File lib/bunny_mock/get_response.rb, line 65
def redelivered
  @hash[:redelivered]
end
Also aliased as: redelivered?
redelivered?()
Alias for: redelivered
routing_key() click to toggle source

@return [String] Routing key this message was published with

# File lib/bunny_mock/get_response.rb, line 76
def routing_key
  @hash[:routing_key]
end
to_hash() click to toggle source

@return [Hash] Hash representation of this delivery info

# File lib/bunny_mock/get_response.rb, line 45
def to_hash
  @hash
end
to_s() click to toggle source

@private

# File lib/bunny_mock/get_response.rb, line 50
def to_s
  to_hash.to_s
end