Module: AutoReconfiguration::Postgres

Defined in:
lib/cf-autoconfig/relational/postgres.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/cf-autoconfig/relational/postgres.rb', line 5

def self.included( base )
  base.send( :alias_method, :original_open, :open)
  base.send( :alias_method, :open, :open_with_cf )
  base.send( :alias_method, :original_connect, :connect)
  base.send( :alias_method, :connect, :connect_with_cf )
  base.send( :alias_method, :original_connect_start, :connect_start)
  base.send( :alias_method, :connect_start, :connect_start_with_cf )
end

Instance Method Details

#connect_start_with_cf(*args) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/cf-autoconfig/relational/postgres.rb', line 36

def connect_start_with_cf(*args)
  connection_string = parse_cf_connection_args(*args)
  if connection_string
    #Send the new connection string to passed block for verification.
    yield connection_string if block_given?
    original_connect_start(connection_string)
  else
    original_connect_start(*args)
  end
end

#connect_with_cf(*args) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/cf-autoconfig/relational/postgres.rb', line 25

def connect_with_cf(*args)
  connection_string = parse_cf_connection_args(*args)
  if connection_string
    #Send the new connection string to passed block for verification.
    yield connection_string if block_given?
    original_connect(connection_string)
  else
    original_connect(*args)
  end
end

#open_with_cf(*args) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/cf-autoconfig/relational/postgres.rb', line 14

def open_with_cf(*args)
  connection_string = parse_cf_connection_args(*args)
  if connection_string
    #Send the new connection string to passed block for verification.
    yield connection_string if block_given?
    original_open(connection_string)
  else
    original_open(*args)
  end
end