Module: Relay::Database
Instance Method Summary collapse
-
#connect!(env:) ⇒ Sequel::Database
Establishes a Sequel connection for the configured environment.
-
#load(env:) ⇒ Hash
Loads the database config for the given environment.
Instance Method Details
#connect!(env:) ⇒ Sequel::Database
Establishes a Sequel connection for the configured environment.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/init/database.rb', line 20 def connect!(env:) settings = load(env:) adapter = settings.fetch("adapter") database = settings.fetch("database") adapter = "sqlite" if adapter == "sqlite3" database = File.(database, Relay.home) unless database.start_with?("/") Sequel.connect( adapter:, database:, max_connections: settings.fetch("pool", 5), pool_timeout: settings.fetch("timeout", 5000) / 1000.0 ) end |