Class: Hermes::Publisher::InMemoryAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/hermes/publisher/in_memory_adapter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInMemoryAdapter

Returns a new instance of InMemoryAdapter.



8
9
10
# File 'lib/hermes/publisher/in_memory_adapter.rb', line 8

def initialize
  @store = []
end

Instance Attribute Details

#storeObject (readonly)

Returns the value of attribute store.



3
4
5
# File 'lib/hermes/publisher/in_memory_adapter.rb', line 3

def store
  @store
end

Class Method Details

.connectObject



5
6
# File 'lib/hermes/publisher/in_memory_adapter.rb', line 5

def self.connect
end

Instance Method Details

#publish(routing_key, payload, properties = {}, options = {}) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/hermes/publisher/in_memory_adapter.rb', line 12

def publish(routing_key, payload, properties = {}, options = {})
  message = { routing_key: routing_key, payload: payload }
  message[:properties] = properties if properties.any?
  message[:options] = options if options.any?

  @store << message
end