Sha256: a645c883089d89d36d0e9c6dde507ee5b060fd2dc64524fa8ec86d6b4477cd17

Contents?: true

Size: 963 Bytes

Versions: 2

Compression:

Stored size: 963 Bytes

Contents

require "sequel"
require "rom"
require "rom/sql"

<%= config[:camel_cased_app_name] %>::Container.namespace :persistence do |container|
  container.finalize :rom do
    init do
      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"]
      container.register "rom", ROM.container(config)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kanji-web-0.3.1 lib/kanji/templates/system/boot/rom.rb.tt
kanji-web-0.3.0 lib/kanji/templates/system/boot/rom.rb.tt