Class: EventSourcing::Aggregate::Manager::Cache

Inherits:
Hash
  • Object
show all
Defined in:
lib/event_sourcing/aggregate/manager/cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(event_bus) ⇒ Cache

Returns a new instance of Cache.



7
8
9
# File 'lib/event_sourcing/aggregate/manager/cache.rb', line 7

def initialize(event_bus)
  @event_bus = event_bus
end

Instance Method Details

#instance_of(aggregate, id) ⇒ Object



11
12
13
# File 'lib/event_sourcing/aggregate/manager/cache.rb', line 11

def instance_of(aggregate, id)
  self[id] ||= aggregate::Actor.spawn!(name: id, supervise: true, args: [@event_bus, @event_bus.get_stream(id)])
end