module RubyEventStore::ROM
Constants
- VERSION
Attributes
env[RW]
Set to a default instance
Public Class Methods
configure(adapter_name, database_uri = ENV['DATABASE_URL'], &block)
click to toggle source
# File lib/ruby_event_store/rom.rb, line 63 def configure(adapter_name, database_uri = ENV['DATABASE_URL'], &block) if adapter_name.is_a?(::ROM::Configuration) # Call config block manually Env.new ::ROM.container(adapter_name.tap(&block), &block) else Env.new ::ROM.container(adapter_name, database_uri, &block) end end
setup(*args) { |config| ... }
click to toggle source
# File lib/ruby_event_store/rom.rb, line 72 def setup(*args, &block) configure(*args) do |config| setup_defaults(config) yield(config) if block end.tap(&method(:configure_defaults)) end
Private Class Methods
configure_defaults(env)
click to toggle source
# File lib/ruby_event_store/rom.rb, line 93 def configure_defaults(env) env.register_error_handler :not_found, lambda { |ex, event_id| case ex when ::ROM::TupleCountMismatchError raise EventNotFound, event_id end } find_adapters(env.rom_container.gateways).each do |adapter| adapter.configure(env) end end
find_adapters(gateways)
click to toggle source
# File lib/ruby_event_store/rom.rb, line 106 def find_adapters(gateways) # Setup for each kind of gateway class gateways.values.map(&:class).uniq.map do |klass| constant = klass.name.split('::')[1].to_sym next unless RubyEventStore::ROM.constants.include?(constant) RubyEventStore::ROM.const_get(constant) end end
setup_defaults(config)
click to toggle source
# File lib/ruby_event_store/rom.rb, line 81 def setup_defaults(config) require_relative 'rom/repositories/stream_entries' require_relative 'rom/repositories/events' config.register_mapper(ROM::Mappers::EventToSerializedRecord) config.register_mapper(ROM::Mappers::StreamEntryToSerializedRecord) find_adapters(config.environment.gateways).each do |adapter| adapter.setup(config) end end
Public Instance Methods
additional_limited_concurrency_for_auto_check()
click to toggle source
TODO: Port from AR to ROM
# File lib/ruby_event_store/spec/rom/event_repository_lint.rb, line 147 def additional_limited_concurrency_for_auto_check positions = rom_container.relations[:stream_entries] .ordered(:forward, default_stream) .map { |entity| entity[:position] } expect(positions).to eq((0..positions.size - 1).to_a) end
cleanup_concurrency_test()
click to toggle source
# File lib/ruby_event_store/spec/rom/event_repository_lint.rb, line 138 def cleanup_concurrency_test rom_helper.close_pool_connection end
count_queries()
click to toggle source
TODO: Port from AR to ROM
# File lib/ruby_event_store/spec/rom/event_repository_lint.rb, line 157 def count_queries count = 0 # counter_f = lambda { |_name, _started, _finished, _unique_id, payload| # count += 1 unless %w[CACHE SCHEMA].include?(payload[:name]) # } # ActiveSupport::Notifications.subscribed(counter_f, "sql.active_record", &block) count end
expect_query(_match)
click to toggle source
TODO: Port from AR to ROM
# File lib/ruby_event_store/spec/rom/event_repository_lint.rb, line 167 def expect_query(_match) count = 0 # counter_f = lambda { |_name, _started, _finished, _unique_id, payload| # count += 1 if match === payload[:sql] # } # ActiveSupport::Notifications.subscribed(counter_f, "sql.active_record", &block) expect(count).to eq(1) end
verify_conncurency_assumptions()
click to toggle source
# File lib/ruby_event_store/spec/rom/event_repository_lint.rb, line 142 def verify_conncurency_assumptions expect(rom_helper.connection_pool_size).to eq(5) end