Class: FakeSmith

Inherits:
Object
  • Object
show all
Defined in:
lib/fake_smith.rb,
lib/fake_smith/version.rb

Defined Under Namespace

Classes: Logger

Constant Summary collapse

VERSION =
"0.0.8"

Class Method Summary collapse

Class Method Details

.add_message(queue_name, message) ⇒ Object



17
18
19
20
# File 'lib/fake_smith.rb', line 17

def self.add_message(queue_name, message)
  messages[queue_name] ||= []
  messages[queue_name] << message
end

.clear_allObject



22
23
24
25
# File 'lib/fake_smith.rb', line 22

def self.clear_all
  clear_subscriptions
  clear_messages
end

.define_subscription(queue_name, &blk) ⇒ Object



9
10
11
# File 'lib/fake_smith.rb', line 9

def self.define_subscription(queue_name, &blk)
  subscriptions[queue_name] = blk
end

.get_messages(queue_name) ⇒ Object



13
14
15
# File 'lib/fake_smith.rb', line 13

def self.get_messages(queue_name)
  messages[queue_name] ||= []
end

.send_message(queue_name, payload, receiver) ⇒ Object



4
5
6
7
# File 'lib/fake_smith.rb', line 4

def self.send_message(queue_name, payload, receiver)
  raise "no subscribers on queue: #{queue_name}" unless subscriptions[queue_name]
  subscriptions[queue_name].call(payload, receiver)
end

.subscribed_queuesObject



27
28
29
# File 'lib/fake_smith.rb', line 27

def self.subscribed_queues
  subscriptions.keys
end