Class: PgBouncerHero::Database
- Inherits:
-
Object
- Object
- PgBouncerHero::Database
show all
- Includes:
- Methods::Basics
- Defined in:
- lib/pgbouncerhero/database.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#clients, #conf, #databases, #lists, #pools, #reload, #shutdown, #stats, #summary, #suspend
Constructor Details
#initialize(group, id, config) ⇒ Database
Returns a new instance of Database.
8
9
10
11
12
13
|
# File 'lib/pgbouncerhero/database.rb', line 8
def initialize(group, id, config)
@id = id
@config = config || {}
@url = URI.parse(config["url"])
@group = group
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
6
7
8
|
# File 'lib/pgbouncerhero/database.rb', line 6
def config
@config
end
|
#group ⇒ Object
Returns the value of attribute group.
6
7
8
|
# File 'lib/pgbouncerhero/database.rb', line 6
def group
@group
end
|
#id ⇒ Object
Returns the value of attribute id.
6
7
8
|
# File 'lib/pgbouncerhero/database.rb', line 6
def id
@id
end
|
Instance Method Details
#connection ⇒ Object
19
20
21
|
# File 'lib/pgbouncerhero/database.rb', line 19
def connection
@connection ||= connection_model.new(host, port, user, password, dbname).connection
end
|
#dbname ⇒ Object
39
40
41
|
# File 'lib/pgbouncerhero/database.rb', line 39
def dbname
@url.path[1..-1] if @url
end
|
#host ⇒ Object
23
24
25
|
# File 'lib/pgbouncerhero/database.rb', line 23
def host
@url.host if @url
end
|
#name ⇒ Object
15
16
17
|
# File 'lib/pgbouncerhero/database.rb', line 15
def name
@name ||= id.to_s
end
|
#password ⇒ Object
35
36
37
|
# File 'lib/pgbouncerhero/database.rb', line 35
def password
@url.password if @url
end
|
#port ⇒ Object
27
28
29
|
# File 'lib/pgbouncerhero/database.rb', line 27
def port
@url.port if @url
end
|
#user ⇒ Object
31
32
33
|
# File 'lib/pgbouncerhero/database.rb', line 31
def user
@url.user if @url
end
|