Module: Moqueue::ObjectMethods
- Defined in:
- lib/moqueue/object_methods.rb
Instance Method Summary collapse
-
#mock_exchange(opts = {}) ⇒ Object
Takes a hash to specify the exchange type and its name.
-
#mock_queue(name = nil) ⇒ Object
Takes a string name as a parameter.
- #mock_queue_and_exchange(name = nil) ⇒ Object
-
#overload_amqp ⇒ Object
Overloads the class-level method calls typically used by AMQP code such as MQ.direct, MQ.queue, MQ.topic, etc.
-
#reset_broker ⇒ Object
Deletes all exchanges and queues from the mock broker.
Instance Method Details
#mock_exchange(opts = {}) ⇒ Object
Takes a hash to specify the exchange type and its name.
topic = mock_exchange(:topic => 'topic exchange')
21 22 23 |
# File 'lib/moqueue/object_methods.rb', line 21 def mock_exchange(opts={}) MockExchange.new(opts) end |
#mock_queue(name = nil) ⇒ Object
Takes a string name as a parameter. Each queue name may only be used once. Multiple calls to #mock_queue with the same name
will return the same object.
14 15 16 |
# File 'lib/moqueue/object_methods.rb', line 14 def mock_queue(name=nil) MockQueue.new(name || "anonymous-#{rand(2**32).to_s(16)}") end |
#mock_queue_and_exchange(name = nil) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/moqueue/object_methods.rb', line 4 def mock_queue_and_exchange(name=nil) queue = mock_queue(name) exchange = mock_exchange exchange.attached_queues << queue [queue, exchange] end |
#overload_amqp ⇒ Object
Overloads the class-level method calls typically used by AMQP code such as MQ.direct, MQ.queue, MQ.topic, etc.
27 28 29 |
# File 'lib/moqueue/object_methods.rb', line 27 def overload_amqp require MOQUEUE_ROOT + "moqueue/overloads" end |
#reset_broker ⇒ Object
Deletes all exchanges and queues from the mock broker. As a consequence of removing queues, all bindings and subscriptions are also deleted.
33 34 35 |
# File 'lib/moqueue/object_methods.rb', line 33 def reset_broker MockBroker.instance.reset! end |