Class: Ductr::SQLite::Adapter
- Inherits:
-
Adapter
- Object
- Adapter
- Ductr::SQLite::Adapter
- Defined in:
- lib/ductr/sqlite/adapter.rb
Overview
The SQLite adapter class implement the required #open! and #close! methods to handle the database connection.
The adapter is registered as :sqlite
to use it, add adapter: sqlite
to the YAML configuration e.g.:
# config/development.yml
adapters:
some_sqlite_database:
adapter: "sqlite"
database: "example.db"
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.
21 22 23 |
# File 'lib/ductr/sqlite/adapter.rb', line 21 def db @db end |
Instance Method Details
#close! ⇒ void
This method returns an undefined value.
Closes the database connection. In the specific case of SQLite, we just destroy the connection instance.
38 39 40 |
# File 'lib/ductr/sqlite/adapter.rb', line 38 def close! @db = nil end |
#open! ⇒ Sequel::Database
Opens the database connection with the adapter's configuration.
28 29 30 |
# File 'lib/ductr/sqlite/adapter.rb', line 28 def open! @db = Sequel.sqlite(**config) end |