Class: PGconn
- Inherits:
-
Object
- Object
- PGconn
- Defined in:
- lib/og/adapter/postgresql/override.rb,
lib/og/adapter/postgresql/override.rb
Overview
:nodoc: all
Class Method Summary collapse
- .new(*args) ⇒ Object (also: connect)
- .new_pre_resque ⇒ Object
Instance Method Summary collapse
-
#initialize(*args) ⇒ PGconn
constructor
A new instance of PGconn.
-
#initialize_pre_on_notice ⇒ Object
Redirect notices from backend to the logger instead of stderr.
- #on_notice(&block) ⇒ Object
- #query(*args) ⇒ Object (also: #exec)
- #query_pre_resque ⇒ Object
-
#server_version ⇒ Object
call-seq: conn.server_version -> Integer.
Constructor Details
#initialize(*args) ⇒ PGconn
Returns a new instance of PGconn.
11 12 13 14 15 |
# File 'lib/og/adapter/postgresql/override.rb', line 11 def initialize(*args) initialize_pre_on_notice(*args) on_notice { || Logger.info } end |
Class Method Details
.new(*args) ⇒ Object Also known as: connect
98 99 100 101 102 |
# File 'lib/og/adapter/postgresql/override.rb', line 98 def new(*args) new_pre_resque(*args) rescue RuntimeError => e raise PGError, e. end |
.new_pre_resque ⇒ Object
96 |
# File 'lib/og/adapter/postgresql/override.rb', line 96 alias_method :new_pre_resque, :new |
Instance Method Details
#initialize_pre_on_notice ⇒ Object
Redirect notices from backend to the logger instead of stderr
10 |
# File 'lib/og/adapter/postgresql/override.rb', line 10 alias_method :initialize_pre_on_notice, :initialize |
#on_notice(&block) ⇒ Object
107 108 109 |
# File 'lib/og/adapter/postgresql/override.rb', line 107 def on_notice(&block) @notice_processor = block end |
#query(*args) ⇒ Object Also known as: exec
86 87 88 89 90 91 |
# File 'lib/og/adapter/postgresql/override.rb', line 86 def query(*args) exec_old(*args) # postgres-pr raises NoMethodError when querying if no conn is available rescue RuntimeError, NoMethodError => e raise PGError, e. end |
#query_pre_resque ⇒ Object
83 |
# File 'lib/og/adapter/postgresql/override.rb', line 83 alias_method :query_pre_resque, :query |
#server_version ⇒ Object
call-seq:
conn.server_version -> Integer
The number is formed by converting the major, minor, and revision numbers into two-decimal-digit numbers and appending them together. For example, version 7.4.2 will be returned as 70402, and version 8.1 will be returned as 80100 (leading zeroes are not shown). Zero is returned if the connection is bad. See also parse_version.
31 32 33 34 35 |
# File 'lib/og/adapter/postgresql/override.rb', line 31 def server_version @server_version ||= parse_version(exec('SHOW server_version').first_value) rescue PGError => e return 0 end |