Class: Bunny::GetResponse

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/bunny/get_response.rb

Overview

Wraps AMQ::Protocol::Basic::GetOk to provide access to the delivery properties as immutable hash as well as methods. Hash representation is created lazily.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#channelBunny::Channel (readonly)



20
21
22
# File 'lib/bunny/get_response.rb', line 20

def channel
  @channel
end

Instance Method Details

#[](k) ⇒ Object

Accesses delivery properties by key

See Also:

  • Hash#[]


36
37
38
39
40
41
42
43
44
45
# File 'lib/bunny/get_response.rb', line 36

def [](k)
  case k
  when :delivery_tag then @get_ok.delivery_tag
  when :redelivered  then @get_ok.redelivered
  when :exchange     then @get_ok.exchange
  when :routing_key  then @get_ok.routing_key
  when :channel      then @channel
  else nil
  end
end

#delivery_tagString



69
70
71
# File 'lib/bunny/get_response.rb', line 69

def delivery_tag
  @get_ok.delivery_tag
end

#each(*args, &block) ⇒ Object

Iterates over the delivery properties

See Also:

  • Enumerable#each


30
31
32
# File 'lib/bunny/get_response.rb', line 30

def each(*args, &block)
  to_hash.each(*args, &block)
end

#exchangeString



80
81
82
# File 'lib/bunny/get_response.rb', line 80

def exchange
  @get_ok.exchange
end

#redeliveredBoolean Also known as: redelivered?



74
75
76
# File 'lib/bunny/get_response.rb', line 74

def redelivered
  @get_ok.redelivered
end

#routing_keyString



85
86
87
# File 'lib/bunny/get_response.rb', line 85

def routing_key
  @get_ok.routing_key
end

#to_hashHash



48
49
50
51
52
53
54
55
56
# File 'lib/bunny/get_response.rb', line 48

def to_hash
  @hash ||= {
    :delivery_tag => @get_ok.delivery_tag,
    :redelivered  => @get_ok.redelivered,
    :exchange     => @get_ok.exchange,
    :routing_key  => @get_ok.routing_key,
    :channel      => @channel
  }
end