Class: Harmoniser::Mock::Channel::MockExchange

Inherits:
Object
  • Object
show all
Defined in:
lib/harmoniser/mock/channel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/harmoniser/mock/channel.rb', line 7

def name
  @name
end

#optsObject (readonly)

Returns the value of attribute opts.



7
8
9
# File 'lib/harmoniser/mock/channel.rb', line 7

def opts
  @opts
end

#typeObject (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_messagesObject



27
28
29
# File 'lib/harmoniser/mock/channel.rb', line 27

def published_messages
  @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