class RubyEventStore::ROM::UnitOfWork

Attributes

env[R]

Public Class Methods

new(rom: ROM.env) click to toggle source
# File lib/ruby_event_store/rom/unit_of_work.rb, line 8
def initialize(rom: ROM.env)
  @env = rom
end

Public Instance Methods

call(**options) { |changesets = []| ... } click to toggle source
# File lib/ruby_event_store/rom/unit_of_work.rb, line 12
def call(**options)
  gateway = @env.rom_container.gateways.fetch(options.delete(:gateway) { :default })

  yield(changesets = [])

  commit!(gateway, changesets, **options)
end
commit!(gateway, changesets, **options) click to toggle source
# File lib/ruby_event_store/rom/unit_of_work.rb, line 20
def commit!(gateway, changesets, **options)
  gateway.transaction(options) { changesets.each(&:commit) }
end