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



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

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#[]


37
38
39
# File 'lib/bunny/return_info.rb', line 37

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

#each(*args, &block) ⇒ Object

Iterates over the returned delivery properties

See Also:

  • Enumerable#each


31
32
33
# File 'lib/bunny/return_info.rb', line 31

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



67
68
69
# File 'lib/bunny/return_info.rb', line 67

def exchange
  @basic_return.exchange
end

#reply_codeInteger

Returns Reply (status) code of the cause.

Returns:

  • (Integer)

    Reply (status) code of the cause



57
58
59
# File 'lib/bunny/return_info.rb', line 57

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



62
63
64
# File 'lib/bunny/return_info.rb', line 62

def reply_text
  @basic_return.reply_text
end

#routing_keyString

Returns Routing key the message has.

Returns:

  • (String)

    Routing key the message has



72
73
74
# File 'lib/bunny/return_info.rb', line 72

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



42
43
44
# File 'lib/bunny/return_info.rb', line 42

def to_hash
  @hash
end