Class: Harmoniser::Mock::Channel::MockExchange
- Inherits:
-
Object
- Object
- Harmoniser::Mock::Channel::MockExchange
- Defined in:
- lib/harmoniser/mock/channel.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, opts = {}) ⇒ MockExchange
constructor
A new instance of MockExchange.
- #on_return(&block) ⇒ Object
- #publish(payload, opts = {}) ⇒ Object
- #published_messages ⇒ Object
- #reset! ⇒ Object
Constructor Details
#initialize(name, opts = {}) ⇒ MockExchange
Returns a new instance of MockExchange.
9 10 11 12 13 14 15 |
# File 'lib/harmoniser/mock/channel.rb', line 9 def initialize(name, opts = {}) @name = name @type = opts[:type] @opts = opts.except(:type) @published_messages = [] @return_handler = nil end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/harmoniser/mock/channel.rb', line 7 def name @name end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
7 8 9 |
# File 'lib/harmoniser/mock/channel.rb', line 7 def opts @opts end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/harmoniser/mock/channel.rb', line 7 def type @type end |
Instance Method Details
#on_return(&block) ⇒ Object
22 23 24 25 |
# File 'lib/harmoniser/mock/channel.rb', line 22 def on_return(&block) @return_handler = block self end |
#publish(payload, opts = {}) ⇒ Object
17 18 19 20 |
# File 'lib/harmoniser/mock/channel.rb', line 17 def publish(payload, opts = {}) @published_messages << {payload: payload, opts: opts} true end |
#published_messages ⇒ Object
27 28 29 |
# File 'lib/harmoniser/mock/channel.rb', line 27 def @published_messages.dup end |
#reset! ⇒ Object
31 32 33 34 |
# File 'lib/harmoniser/mock/channel.rb', line 31 def reset! @published_messages.clear @return_handler = nil end |