Class: Bunny::ReturnInfo

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

Overview

Wraps AMQ::Protocol::Basic::Return to provide access to the delivery properties as immutable hash as well as methods.

Instance Method Summary collapse

Constructor Details

#initialize(basic_return) ⇒ ReturnInfo

API



17
18
19
20
21
22
23
24
25
# File 'lib/bunny/return_info.rb', line 17

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

Instance Method Details

#[](k) ⇒ Object

Accesses returned delivery properties by key

See Also:

  • Hash#[]


35
36
37
# File 'lib/bunny/return_info.rb', line 35

def [](k)
  @hash[k]
end

#each(*args, &block) ⇒ Object

Iterates over the returned delivery properties

See Also:

  • Enumerable#each


29
30
31
# File 'lib/bunny/return_info.rb', line 29

def each(*args, &block)
  @hash.each(*args, &block)
end

#exchangeString

Returns Exchange the message was published to

Returns:

  • (String)

    Exchange the message was published to



65
66
67
# File 'lib/bunny/return_info.rb', line 65

def exchange
  @basic_return.exchange
end

#reply_codeInteger

Returns Reply (status) code of the cause

Returns:

  • (Integer)

    Reply (status) code of the cause



55
56
57
# File 'lib/bunny/return_info.rb', line 55

def reply_code
  @basic_return.reply_code
end

#reply_textInteger

Returns Reply (status) text of the cause, explaining why the message was returned

Returns:

  • (Integer)

    Reply (status) text of the cause, explaining why the message was returned



60
61
62
# File 'lib/bunny/return_info.rb', line 60

def reply_text
  @basic_return.reply_text
end

#routing_keyString

Returns Routing key the message has

Returns:

  • (String)

    Routing key the message has



70
71
72
# File 'lib/bunny/return_info.rb', line 70

def routing_key
  @basic_return.routing_key
end

#to_hashHash

Returns Hash representation of this returned delivery info

Returns:

  • (Hash)

    Hash representation of this returned delivery info



40
41
42
# File 'lib/bunny/return_info.rb', line 40

def to_hash
  @hash
end