Class: Forty::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/forty/database.rb,
lib/forty/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#databaseObject

Returns the value of attribute database.



9
10
11
# File 'lib/forty/database.rb', line 9

def database
  @database
end

#hostObject

Returns the value of attribute host.



5
6
7
# File 'lib/forty/database.rb', line 5

def host
  @host
end

#nameObject

Returns the value of attribute name.



23
24
25
# File 'lib/forty/configuration.rb', line 23

def name
  @name
end

#passwordObject

Returns the value of attribute password.



8
9
10
# File 'lib/forty/database.rb', line 8

def password
  @password
end

#portObject

Returns the value of attribute port.



6
7
8
# File 'lib/forty/database.rb', line 6

def port
  @port
end

#userObject

Returns the value of attribute user.



7
8
9
# File 'lib/forty/database.rb', line 7

def user
  @user
end

Instance Method Details

#execute(statement) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/forty/database.rb', line 11

def execute(statement)
  @db ||= PG.connect(
    host: self.host,
    port: self.port,
    user: self.user,
    password: self.password,
    dbname: self.database
  )

  @db.exec(statement)
end