Class: Convergence::DatabaseConnector::PostgresConnector
- Inherits:
-
Object
- Object
- Convergence::DatabaseConnector::PostgresConnector
- Defined in:
- lib/convergence/database_connector/postgres_connector.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #client(database_name = @config.database) ⇒ Object
-
#initialize(config) ⇒ PostgresConnector
constructor
A new instance of PostgresConnector.
- #schema_client ⇒ Object
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
#config ⇒ Object (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_client ⇒ Object
22 23 24 |
# File 'lib/convergence/database_connector/postgres_connector.rb', line 22 def schema_client client end |