Class: Convergence::DatabaseConnector::PostgresConnector

Inherits:
Object
  • Object
show all
Defined in:
lib/convergence/database_connector/postgres_connector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ PostgresConnector

Returns a new instance of PostgresConnector.



7
8
9
# File 'lib/convergence/database_connector/postgres_connector.rb', line 7

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/convergence/database_connector/postgres_connector.rb', line 5

def config
  @config
end

Instance Method Details

#client(database_name = @config.database) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/convergence/database_connector/postgres_connector.rb', line 11

def client(database_name = @config.database)
  @clients ||= {}
  @clients[database_name] ||= PG::Connection.new(
    host: @config.host,
    port: @config.port,
    user: @config.username,
    password: @config.password,
    dbname: database_name
  )
end

#schema_clientObject



22
23
24
# File 'lib/convergence/database_connector/postgres_connector.rb', line 22

def schema_client
  client
end