lib/pg_conn.rb in pg_conn-0.3.4 vs lib/pg_conn.rb in pg_conn-0.3.5

- old
+ new

@@ -96,10 +96,11 @@ # Note that the connection hash and the connection string may support more # parameters than documented here. Consult # https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING # for the full list # + # TODO: Change to 'initialize(*args, **opts)' def initialize(*args) if args.last.is_a?(Hash) @field_name_class = args.last.delete(:field_name_class) || Symbol @timestamp = args.last.delete(:timestamp) args.pop if args.last.empty? @@ -178,21 +179,21 @@ # Close the database connection def terminate() @pg_connection.close if @pg_connection && !@pg_connection.finished? end - def self.new(*args, &block) + def self.new(*args, **opts, &block) if block_given? begin object = Connection.allocate - object.send(:initialize, *args) + object.send(:initialize, *args, **opts) yield(object) # if object.pg_connection ensure object.terminate if object.pg_connection end else - super(*args) + super(*args, **opts) end end # :call-seq: # exist?(query) @@ -634,10 +635,10 @@ # # TODO: Fix silent by not handling exceptions def pg_exec(arg, fail: true, silent: false) if @pg_connection begin - last_stmt = nil # To make the current SQL statement visible to the rescue clause + last_stmt = nil # To make the current SQL statement visible to the rescue clause. FIXME Not used? if arg.is_a?(String) return nil if arg == "" last_stmt = arg @pg_connection.exec(last_stmt) else