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 return properties as immutable hash as well as methods. Hash representation is created lazily.

Instance Method Summary collapse

Constructor Details

#initialize(basic_return) ⇒ ReturnInfo

API



19
20
21
# File 'lib/bunny/return_info.rb', line 19

def initialize(basic_return)
  @basic_return = basic_return
end

Instance Method Details

#[](k) ⇒ Object

Accesses returned delivery properties by key

See Also:

  • Hash#[]


31
32
33
34
35
36
37
38
39
# File 'lib/bunny/return_info.rb', line 31

def [](k)
  case k
  when :reply_code  then @basic_return.reply_code
  when :reply_text  then @basic_return.reply_text
  when :exchange    then @basic_return.exchange
  when :routing_key then @basic_return.routing_key
  else nil
  end
end

#each(*args, &block) ⇒ Object

Iterates over the returned delivery properties

See Also:

  • Enumerable#each


25
26
27
# File 'lib/bunny/return_info.rb', line 25

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

#exchangeString

Returns Exchange the message was published to.

Returns:

  • Exchange the message was published to



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

def exchange
  @basic_return.exchange
end

#reply_codeInteger

Returns Reply (status) code of the cause.

Returns:

  • Reply (status) code of the cause



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

def reply_code
  @basic_return.reply_code
end

#reply_textInteger

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

Returns:

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



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

def reply_text
  @basic_return.reply_text
end

#routing_keyString

Returns Routing key the message has.

Returns:

  • Routing key the message has



77
78
79
# File 'lib/bunny/return_info.rb', line 77

def routing_key
  @basic_return.routing_key
end

#to_hashHash

Returns Hash representation of this returned delivery info.

Returns:

  • Hash representation of this returned delivery info



42
43
44
45
46
47
48
49
# File 'lib/bunny/return_info.rb', line 42

def to_hash
  @hash ||= {
    :reply_code   => @basic_return.reply_code,
    :reply_text   => @basic_return.reply_text,
    :exchange     => @basic_return.exchange,
    :routing_key  => @basic_return.routing_key
  }
end