Class: Bucky::Core::Database::DbConnector

Inherits:
Object
  • Object
show all
Defined in:
lib/bucky/core/database/db_connector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDbConnector

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

#conObject (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

Parameters:

  • db_name (String) (defaults to: 'bucky_test')

    database name



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

#disconnectObject

Disconnect to database



23
24
25
# File 'lib/bucky/core/database/db_connector.rb', line 23

def disconnect
  @con.disconnect
end