Sha256: ed38923a6b2adf8ac8f6f8af526a2ee2d47eaee9624ad084e25293e8a7e0f9c4

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

<%= config[:camel_cased_app_name] %>::Container.namespace "persistence" do |container|
  container.finalize :rom do
    init do
      require "sequel"
      require "rom"
      require "rom/sql"

      use :settings
      use :monitor

      ROM::SQL.load_extensions :postgres

      Sequel.database_timezone = :utc
      Sequel.application_timezone = :local

      rom_config = ROM::Configuration.new(
        :sql,
        container["settings"].database_url,
        extensions: %i[error_sql pg_array pg_json],
      )

      rom_config.plugin :sql, relations: :instrumentation do |plugin_config|
        plugin_config.notifications = notifications
      end

      rom_config.plugin :sql, relations: :auto_restrictions

      container.register "config", rom_config
      container.register "db", rom_config.gateways[:default].connection
    end

    start do
      config = container["persistence.config"]
      config.auto_registration container.root.join("lib/persistence")

      container.register "rom", ROM.container(config)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dry-web-roda-0.7.5 lib/dry/web/roda/templates/rom.rb.tt
dry-web-roda-0.7.4 lib/dry/web/roda/templates/rom.rb.tt
dry-web-roda-0.7.3 lib/dry/web/roda/templates/rom.rb.tt
dry-web-roda-0.7.2 lib/dry/web/roda/templates/rom.rb.tt
dry-web-roda-0.7.1 lib/dry/web/roda/templates/rom.rb.tt
dry-web-roda-0.7.0 lib/dry/web/roda/templates/rom.rb.tt