Class: RosettaQueue::Gateway::FakeAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/rosetta_queue/adapters/fake.rb

Instance Method Summary collapse

Constructor Details

#initialize(adapter_settings = {}) ⇒ FakeAdapter

Returns a new instance of FakeAdapter.



6
7
8
9
# File 'lib/rosetta_queue/adapters/fake.rb', line 6

def initialize(adapter_settings = {})
  @messages = []
  @open = true
end

Instance Method Details

#disconnectObject



23
24
25
# File 'lib/rosetta_queue/adapters/fake.rb', line 23

def disconnect
  @open = false
end

#messages_sent_to(queue) ⇒ Object



15
16
17
# File 'lib/rosetta_queue/adapters/fake.rb', line 15

def messages_sent_to(queue)
  (queue ? @messages.select{|message| message['queue'] == queue} : @messages).map{|m| m['message']}
end

#open?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/rosetta_queue/adapters/fake.rb', line 27

def open?
  @open == true
end

#queuesObject



19
20
21
# File 'lib/rosetta_queue/adapters/fake.rb', line 19

def queues
  @messages.map {|message| message['queue']}
end

#send_message(queue, message, headers) ⇒ Object



11
12
13
# File 'lib/rosetta_queue/adapters/fake.rb', line 11

def send_message(queue, message, headers)
  @messages << {'queue' => queue, 'message' => RosettaQueue::Filters::process_receiving(message), 'headers' => headers}
end