Class: RubyCode::Database
- Inherits:
-
Object
- Object
- RubyCode::Database
- Defined in:
- lib/rubycode/database.rb
Overview
Database connection manager for all models
Class Attribute Summary collapse
-
.db ⇒ Object
Returns the value of attribute db.
Class Method Summary collapse
Class Attribute Details
.db ⇒ Object
Returns the value of attribute db.
10 11 12 |
# File 'lib/rubycode/database.rb', line 10 def db @db end |
Class Method Details
.connect(db_path: nil) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/rubycode/database.rb', line 12 def connect(db_path: nil) path = db_path || default_db_path @db = Sequel.sqlite(path) run_migrations @db end |
.connection ⇒ Object
24 25 26 |
# File 'lib/rubycode/database.rb', line 24 def connection @db || connect end |
.disconnect ⇒ Object
19 20 21 22 |
# File 'lib/rubycode/database.rb', line 19 def disconnect @db&.disconnect @db = nil end |