Class: Brown::QueueFactory
- Inherits:
-
Object
- Object
- Brown::QueueFactory
- Defined in:
- lib/brown/queue_factory.rb
Instance Method Summary collapse
-
#each_queue ⇒ Object
Passes each queue to the supplied block.
-
#initialize ⇒ QueueFactory
constructor
A new instance of QueueFactory.
-
#queues ⇒ Object
Returns all queues as a hash, with the queue name being the key.
-
#receiver(queue_name, opts = {}, &blk) ⇒ Object
Convenience method that returns a Receiver object.
-
#sender(queue_name, opts = {}, &blk) ⇒ Object
Convenience method that returns a Sender object.
Constructor Details
#initialize ⇒ QueueFactory
Returns a new instance of QueueFactory.
4 5 6 |
# File 'lib/brown/queue_factory.rb', line 4 def initialize @cache = {} end |
Instance Method Details
#each_queue ⇒ Object
Passes each queue to the supplied block.
23 24 25 26 27 |
# File 'lib/brown/queue_factory.rb', line 23 def each_queue @cache.values.each do |queue| yield queue if block_given? end end |
#queues ⇒ Object
Returns all queues as a hash, with the queue name being the key.
30 31 32 |
# File 'lib/brown/queue_factory.rb', line 30 def queues @cache end |
#receiver(queue_name, opts = {}, &blk) ⇒ Object
Convenience method that returns a Receiver object.
16 17 18 19 20 |
# File 'lib/brown/queue_factory.rb', line 16 def receiver(queue_name, opts={}, &blk) k = "receiver:#{queue_name}" @cache[k] ||= Brown::Receiver.new(queue_name, opts) blk.call(@cache[k]) end |