class Novel::SagaRepository
Attributes
adapter[R]
Public Class Methods
new(adapter: RepositoryAdapters::Memory.new)
click to toggle source
# File lib/novel/saga_repository.rb, line 8 def initialize(adapter: RepositoryAdapters::Memory.new) @adapter = adapter end
Public Instance Methods
find_or_create_context(saga_id, params)
click to toggle source
# File lib/novel/saga_repository.rb, line 12 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
persist_context(context, **params)
click to toggle source
# File lib/novel/saga_repository.rb, line 16 def persist_context(context, **params) new_context = Context.new({ **context.to_h, **params }) adapter.persist_context(context.id, new_context) new_context end