Class: FlareUp::Connection
- Inherits:
-
Object
- Object
- FlareUp::Connection
- Defined in:
- lib/flare_up/connection.rb
Instance Attribute Summary collapse
-
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
-
#dbname ⇒ Object
Returns the value of attribute dbname.
-
#host ⇒ Object
Returns the value of attribute host.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#execute(statement) ⇒ Object
TODO - Not quite sure how to test this; perhaps fold connect/execute into TODO one method so we can close connections in case of failure, etc.
-
#initialize(host, dbname, user, password) ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize(host, dbname, user, password) ⇒ Connection
23 24 25 26 27 28 29 30 31 |
# File 'lib/flare_up/connection.rb', line 23 def initialize(host, dbname, user, password) @host = host @dbname = dbname @user = user @password = password @port = 5439 @connect_timeout = 5 end |
Instance Attribute Details
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
21 22 23 |
# File 'lib/flare_up/connection.rb', line 21 def connect_timeout @connect_timeout end |
#dbname ⇒ Object
Returns the value of attribute dbname.
18 19 20 |
# File 'lib/flare_up/connection.rb', line 18 def dbname @dbname end |
#host ⇒ Object
Returns the value of attribute host.
16 17 18 |
# File 'lib/flare_up/connection.rb', line 16 def host @host end |
#password ⇒ Object
Returns the value of attribute password.
20 21 22 |
# File 'lib/flare_up/connection.rb', line 20 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
17 18 19 |
# File 'lib/flare_up/connection.rb', line 17 def port @port end |
#user ⇒ Object
Returns the value of attribute user.
19 20 21 |
# File 'lib/flare_up/connection.rb', line 19 def user @user end |
Instance Method Details
#execute(statement) ⇒ Object
TODO - Not quite sure how to test this; perhaps fold connect/execute into TODO one method so we can close connections in case of failure, etc.
35 36 37 38 |
# File 'lib/flare_up/connection.rb', line 35 def execute(statement) @pg_conn ||= connect @pg_conn.exec(statement) end |