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.
13 14 15 |
# File 'lib/bucky/core/database/db_connector.rb', line 13 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
19 20 21 22 23 24 25 |
# File 'lib/bucky/core/database/db_connector.rb', line 19 def connect(db_name = 'bucky_test') @con = if $debug @test_db_config[db_name.to_sym] else Sequel.connect(@test_db_config[db_name.to_sym], encoding: 'utf8') end end |
#disconnect ⇒ Object
Disconnect to database
28 29 30 |
# File 'lib/bucky/core/database/db_connector.rb', line 28 def disconnect @con.disconnect end |