Class: RedshiftPG::Connection
- Inherits:
-
Object
- Object
- RedshiftPG::Connection
- Defined in:
- lib/redshift_pg/connection.rb
Constant Summary collapse
- SQL_TO_PG_KEY_MAP =
{ 'username' => 'user', 'database' => 'dbname' }
- PG_INCLUDE_KEYS =
%w(host dbname port user password)
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config) ⇒ Connection
constructor
A new instance of Connection.
- #pg_connection ⇒ Object
- #reconnect_on_failure(&block) ⇒ Object
Constructor Details
#initialize(config) ⇒ Connection
Returns a new instance of Connection.
13 14 15 |
# File 'lib/redshift_pg/connection.rb', line 13 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/redshift_pg/connection.rb', line 4 def config @config end |
Instance Method Details
#pg_connection ⇒ Object
26 27 28 |
# File 'lib/redshift_pg/connection.rb', line 26 def pg_connection @pg_connection ||= connect! end |
#reconnect_on_failure(&block) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/redshift_pg/connection.rb', line 17 def reconnect_on_failure(&block) begin return yield rescue PG::UnableToSend, PG::ConnectionBad pg_connection.reset return yield end end |