Class: Sandthorn::EventStores
- Inherits:
-
Object
- Object
- Sandthorn::EventStores
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/sandthorn/event_stores.rb
Instance Method Summary collapse
- #add(name, event_store) ⇒ Object (also: #[]=)
- #add_many(stores) ⇒ Object
- #by_name(name) ⇒ Object (also: #[])
- #default_store ⇒ Object
- #default_store=(store) ⇒ Object
-
#initialize(stores = nil) ⇒ EventStores
constructor
A new instance of EventStores.
- #map_types(hash) ⇒ Object
- #stores ⇒ Object
Constructor Details
#initialize(stores = nil) ⇒ EventStores
Returns a new instance of EventStores.
10 11 12 13 |
# File 'lib/sandthorn/event_stores.rb', line 10 def initialize(stores = nil) @store_map = Hash.new add_initial(stores) end |
Instance Method Details
#add(name, event_store) ⇒ Object Also known as: []=
15 16 17 |
# File 'lib/sandthorn/event_stores.rb', line 15 def add(name, event_store) store_map[name] = event_store end |
#add_many(stores) ⇒ Object
20 21 22 23 24 |
# File 'lib/sandthorn/event_stores.rb', line 20 def add_many(stores) stores.each_pair do |name, store| add(name, store) end end |
#by_name(name) ⇒ Object Also known as: []
26 27 28 |
# File 'lib/sandthorn/event_stores.rb', line 26 def by_name(name) store_map[name] || default_store end |
#default_store ⇒ Object
31 32 33 |
# File 'lib/sandthorn/event_stores.rb', line 31 def default_store store_map.fetch(:default) end |
#default_store=(store) ⇒ Object
35 36 37 |
# File 'lib/sandthorn/event_stores.rb', line 35 def default_store=(store) store_map[:default] = store end |
#map_types(hash) ⇒ Object
43 44 45 46 47 |
# File 'lib/sandthorn/event_stores.rb', line 43 def map_types(hash) hash.each_pair do |event_store, aggregate_types| map_aggregate_types_to_event_store(aggregate_types, event_store) end end |
#stores ⇒ Object
39 40 41 |
# File 'lib/sandthorn/event_stores.rb', line 39 def stores store_map.values end |