Class: Bucky::Core::Database::DbConnector
- Inherits:
-
Object
- Object
- Bucky::Core::Database::DbConnector
- Defined in:
- lib/bucky/core/database/db_connector.rb
Instance Attribute Summary collapse
-
#con ⇒ Object
readonly
Returns the value of attribute con.
Instance Method Summary collapse
-
#connect(db_name = 'bucky_test') ⇒ Object
Connect to database.
-
#disconnect ⇒ Object
Disconnect to database.
-
#initialize ⇒ DbConnector
constructor
A new instance of DbConnector.
Constructor Details
#initialize ⇒ DbConnector
Returns a new instance of DbConnector.
12 13 14 |
# File 'lib/bucky/core/database/db_connector.rb', line 12 def initialize @test_db_config = Bucky::Utils::Config.instance[:test_db] end |
Instance Attribute Details
#con ⇒ Object (readonly)
Returns the value of attribute con.
11 12 13 |
# File 'lib/bucky/core/database/db_connector.rb', line 11 def con @con end |
Instance Method Details
#connect(db_name = 'bucky_test') ⇒ Object
Connect to database
18 19 20 |
# File 'lib/bucky/core/database/db_connector.rb', line 18 def connect(db_name = 'bucky_test') @con = Sequel.connect(@test_db_config[db_name.to_sym], encoding: 'utf8') end |
#disconnect ⇒ Object
Disconnect to database
23 24 25 |
# File 'lib/bucky/core/database/db_connector.rb', line 23 def disconnect @con.disconnect end |