Class: BunnyHair::Consumer
- Inherits:
-
Object
- Object
- BunnyHair::Consumer
- Defined in:
- lib/bunny_hair/consumer.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#consumer_tag ⇒ Object
Returns the value of attribute consumer_tag.
-
#exclusive ⇒ Object
readonly
Returns the value of attribute exclusive.
-
#no_ack ⇒ Object
readonly
Returns the value of attribute no_ack.
-
#queue ⇒ Object
readonly
This interface has been stolen from Bunny itself github.com/ruby-amqp/bunny/blob/master/lib/bunny/consumer.rb specific commit: github.com/ruby-amqp/bunny/blob/f7844397ffcb1ef8b7a377c59335a154a6adfc26/lib/bunny/consumer.rb.
Instance Method Summary collapse
- #call(*args) ⇒ Object (also: #handle_delivery)
- #cancel ⇒ Object
-
#initialize(queue) ⇒ Consumer
constructor
A new instance of Consumer.
- #on_delivery(&block) ⇒ Object
Constructor Details
#initialize(queue) ⇒ Consumer
Returns a new instance of Consumer.
13 14 15 16 17 |
# File 'lib/bunny_hair/consumer.rb', line 13 def initialize(queue) @queue = queue || raise(ArgumentError, "queue is nil") self.queue.consumers << self end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
9 10 11 |
# File 'lib/bunny_hair/consumer.rb', line 9 def arguments @arguments end |
#consumer_tag ⇒ Object
Returns the value of attribute consumer_tag.
8 9 10 |
# File 'lib/bunny_hair/consumer.rb', line 8 def consumer_tag @consumer_tag end |
#exclusive ⇒ Object (readonly)
Returns the value of attribute exclusive.
11 12 13 |
# File 'lib/bunny_hair/consumer.rb', line 11 def exclusive @exclusive end |
#no_ack ⇒ Object (readonly)
Returns the value of attribute no_ack.
10 11 12 |
# File 'lib/bunny_hair/consumer.rb', line 10 def no_ack @no_ack end |
#queue ⇒ Object (readonly)
This interface has been stolen from Bunny itself github.com/ruby-amqp/bunny/blob/master/lib/bunny/consumer.rb specific commit: github.com/ruby-amqp/bunny/blob/f7844397ffcb1ef8b7a377c59335a154a6adfc26/lib/bunny/consumer.rb
7 8 9 |
# File 'lib/bunny_hair/consumer.rb', line 7 def queue @queue end |
Instance Method Details
#call(*args) ⇒ Object Also known as: handle_delivery
28 29 30 |
# File 'lib/bunny_hair/consumer.rb', line 28 def call(*args) @on_delivery.call(*args) if @on_delivery end |
#cancel ⇒ Object
24 25 26 |
# File 'lib/bunny_hair/consumer.rb', line 24 def cancel queue.consumers.delete(self) end |
#on_delivery(&block) ⇒ Object
19 20 21 22 |
# File 'lib/bunny_hair/consumer.rb', line 19 def on_delivery(&block) @on_delivery = block self end |