class Aggregates::InMemoryStorageBackend
This is an extremely simple storage backend that retains all events and commands in process memory. This method does not persist beyond application restarts and should generally only be used in testing.
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/aggregates/in_memory_storage_backend.rb, line 8 def initialize super() @events = {} @commands = {} end
Public Instance Methods
load_commands_by_aggregate_id(aggregate_id)
click to toggle source
# File lib/aggregates/in_memory_storage_backend.rb, line 27 def load_commands_by_aggregate_id(aggregate_id) @commands[aggregate_id] ||= [] end
load_events_by_aggregate_id(aggregate_id)
click to toggle source
# File lib/aggregates/in_memory_storage_backend.rb, line 23 def load_events_by_aggregate_id(aggregate_id) @events[aggregate_id] ||= [] end
store_command(command)
click to toggle source
# File lib/aggregates/in_memory_storage_backend.rb, line 15 def store_command(command) load_commands_by_aggregate_id(command.aggregate_id) << command end
store_event(event)
click to toggle source
# File lib/aggregates/in_memory_storage_backend.rb, line 19 def store_event(event) load_events_by_aggregate_id(event.aggregate_id) << event end