Class: FlareUp::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/flare_up/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_timeoutObject

Returns the value of attribute connect_timeout.



21
22
23
# File 'lib/flare_up/connection.rb', line 21

def connect_timeout
  @connect_timeout
end

#dbnameObject

Returns the value of attribute dbname.



18
19
20
# File 'lib/flare_up/connection.rb', line 18

def dbname
  @dbname
end

#hostObject

Returns the value of attribute host.



16
17
18
# File 'lib/flare_up/connection.rb', line 16

def host
  @host
end

#passwordObject

Returns the value of attribute password.



20
21
22
# File 'lib/flare_up/connection.rb', line 20

def password
  @password
end

#portObject

Returns the value of attribute port.



17
18
19
# File 'lib/flare_up/connection.rb', line 17

def port
  @port
end

#userObject

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