Class: Ductr::Postgres::Adapter
- Inherits:
-
Adapter
- Object
- Adapter
- Ductr::Postgres::Adapter
- Defined in:
- lib/ductr/postgres/adapter.rb
Overview
The PostgreSQL adapter implement the required #open! and #close! methods to handle the database connection.
The adapter is registered as :postgres
to use it, add adapter: postgres
to the YAML configuration e.g.:
# config/development.yml
adapters:
some_postgres_database:
adapter: postgres
host: localhost
user: postgres
password: s3cr3t
database: example
Instance Attribute Summary collapse
-
#db ⇒ Sequel::Database?
readonly
The database connection instance.
Instance Method Summary collapse
-
#close! ⇒ void
Closes the database connection.
-
#open! ⇒ Sequel::Database
Opens the database connection with the adapter's configuration.
Instance Attribute Details
#db ⇒ Sequel::Database? (readonly)
Returns The database connection instance.
29 30 31 |
# File 'lib/ductr/postgres/adapter.rb', line 29 def db @db end |
Instance Method Details
#close! ⇒ void
This method returns an undefined value.
Closes the database connection.
50 51 52 |
# File 'lib/ductr/postgres/adapter.rb', line 50 def close! @db.disconnect end |
#open! ⇒ Sequel::Database
Opens the database connection with the adapter's configuration.
36 37 38 39 40 41 42 43 |
# File 'lib/ductr/postgres/adapter.rb', line 36 def open! @db = Sequel.postgres(**config) @db.extension(:pg_streaming) @db.stream_all_queries = true @db end |