Remove persistence provider

This commit is contained in:
2024-08-05 18:44:34 +10:00
parent 2ada50cbcd
commit 79a56baa82
2 changed files with 0 additions and 49 deletions

View File

@@ -1,45 +0,0 @@
# frozen_string_literal: true
Hanami.app.register_provider :persistence, namespace: true do
prepare do
require "rom-changeset"
require "rom/core"
require "rom/sql"
# TODO(Hanami): As part of built-in rom setup, configure ROM with app inflector
silence_warnings { ROM::Inflector = Hanami.app["inflector"] }
rom_config = ROM::Configuration.new(:sql, target["settings"].database_url)
rom_config.plugin(:sql, relations: :instrumentation) do |plugin_config|
plugin_config.notifications = target["notifications"]
end
rom_config.plugin(:sql, relations: :auto_restrictions)
register "config", rom_config
register "db", rom_config.gateways[:default].connection
end
start do
rom_config = target["persistence.config"]
rom_config.auto_registration(
target.root.join("app"),
namespace: Hanami.app.namespace.to_s
)
register "rom", ROM.container(rom_config)
end
stop do
target["persistence.rom"].disconnect
end
define_method(:silence_warnings) do |&block|
orig_verbose = $VERBOSE
$VERBOSE = nil
result = block.call
$VERBOSE = orig_verbose
result
end
end

View File

@@ -6,10 +6,6 @@ require_relative "db/database_cleaner"
require_relative "db/factory" require_relative "db/factory"
RSpec.configure do |config| RSpec.configure do |config|
config.before :suite do
Hanami.app.start :persistence
end
config.include Test::DB::Helpers, :db config.include Test::DB::Helpers, :db
config.include(Test::DB::FactoryHelper.new, factory: nil) config.include(Test::DB::FactoryHelper.new, factory: nil)