Class: Consumer::Substitute::Consumer

Inherits:
Object
  • Object
show all
Defined in:
lib/consumer/substitute.rb

Instance Method Summary collapse

Instance Method Details

#call(message_data) ⇒ Object



8
9
10
# File 'lib/consumer/substitute.rb', line 8

def call(message_data)
  dispatched_messages << message_data
end

#dispatched?(message_data = nil, &block) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
# File 'lib/consumer/substitute.rb', line 16

def dispatched?(message_data=nil, &block)
  if message_data.nil?
    block ||= proc { true }
  else
    block ||= proc { |msg| message_data == msg }
  end

  dispatched_messages.any?(&block)
end

#dispatched_messagesObject



12
13
14
# File 'lib/consumer/substitute.rb', line 12

def dispatched_messages
  @dispatched_messages ||= []
end