Class: Promiscuous::AMQP::Fake
- Inherits:
-
Object
- Object
- Promiscuous::AMQP::Fake
- Defined in:
- lib/promiscuous/amqp/fake.rb
Defined Under Namespace
Modules: Subscriber
Instance Attribute Summary collapse
-
#messages ⇒ Object
Returns the value of attribute messages.
Class Method Summary collapse
Instance Method Summary collapse
- #connect ⇒ Object
- #connected? ⇒ Boolean
- #disconnect ⇒ Object
- #get_next_message ⇒ Object
- #get_next_payload ⇒ Object
- #num_messages ⇒ Object
- #publish(options = {}) ⇒ Object
Instance Attribute Details
#messages ⇒ Object
Returns the value of attribute messages.
2 3 4 |
# File 'lib/promiscuous/amqp/fake.rb', line 2 def @messages end |
Class Method Details
.backend ⇒ Object
5 6 7 |
# File 'lib/promiscuous/amqp/fake.rb', line 5 def backend Promiscuous::AMQP.backend end |
Instance Method Details
#connect ⇒ Object
11 12 13 |
# File 'lib/promiscuous/amqp/fake.rb', line 11 def connect @messages = [] end |
#connected? ⇒ Boolean
18 19 20 |
# File 'lib/promiscuous/amqp/fake.rb', line 18 def connected? true end |
#disconnect ⇒ Object
15 16 |
# File 'lib/promiscuous/amqp/fake.rb', line 15 def disconnect end |
#get_next_message ⇒ Object
32 33 34 |
# File 'lib/promiscuous/amqp/fake.rb', line 32 def @messages.shift end |
#get_next_payload ⇒ Object
36 37 38 39 |
# File 'lib/promiscuous/amqp/fake.rb', line 36 def get_next_payload msg = msg && JSON.parse(msg[:payload]) end |
#num_messages ⇒ Object
28 29 30 |
# File 'lib/promiscuous/amqp/fake.rb', line 28 def @messages.count end |
#publish(options = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/promiscuous/amqp/fake.rb', line 22 def publish(={}) Promiscuous.debug "[publish (fake)] #{[:exchange].try(:name) || "default"}/#{[:key]} #{[:payload]}" @messages << [:on_confirm].try(:call) end |