Sha256: ceeb2bfd1c88c4419bf4a6fc36052239abf68f93dda26c16615202dfaa8e79d1
Contents?: true
Size: 609 Bytes
Versions: 1
Compression:
Stored size: 609 Bytes
Contents
require 'novel/repository_adapters/memory' require 'novel/repository_adapters/redis' module Novel class SagaRepository attr_reader :adapter def initialize(adapter: RepositoryAdapters::Memory.new) @adapter = adapter end def find_or_create_context(saga_id, params) adapter.find_context(saga_id) || adapter.persist_context(saga_id, Context.new(id: saga_id, params: params)) end def persist_context(context, **params) new_context = Context.new({ **context.to_h, **params }) adapter.persist_context(context.id, new_context) new_context end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
novel-0.3.0 | lib/novel/saga_repository.rb |