Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
vertx-pg-client.pg_client.rb Maven / Gradle / Ivy
require 'vertx-pg-client/pg_pool'
require 'vertx-pg-client/tuple'
require 'vertx/vertx'
require 'vertx-pg-client/pg_connection'
require 'vertx-pg-client/row'
require 'vertx-pg-client/pg_result'
require 'vertx/util/utils.rb'
# Generated from com.julienviet.pgclient.PgClient
module VertxPgClient
# Defines the client operations with a Postgres Database.
class PgClient
# @private
# @param j_del [::VertxPgClient::PgClient] the java delegate
def initialize(j_del)
@j_del = j_del
end
# @private
# @return [::VertxPgClient::PgClient] the underlying java delegate
def j_del
@j_del
end
@@j_api_type = Object.new
def @@j_api_type.accept?(obj)
obj.class == PgClient
end
def @@j_api_type.wrap(obj)
PgClient.new(obj)
end
def @@j_api_type.unwrap(obj)
obj.j_del
end
def self.j_api_type
@@j_api_type
end
def self.j_class
Java::ComJulienvietPgclient::PgClient.java_class
end
# Like {::VertxPgClient::PgClient#pool} with a specific instance.
# @overload pool(options)
# @param [Hash] options the options for creating the pool
# @overload pool(vertx,options)
# @param [::Vertx::Vertx] vertx
# @param [Hash] options
# @return [::VertxPgClient::PgPool]
def self.pool(param_1=nil,param_2=nil)
if param_1.class == Hash && !block_given? && param_2 == nil
return ::Vertx::Util::Utils.safe_create(Java::ComJulienvietPgclient::PgClient.java_method(:pool, [Java::ComJulienvietPgclient::PgPoolOptions.java_class]).call(Java::ComJulienvietPgclient::PgPoolOptions.new(::Vertx::Util::Utils.to_json_object(param_1))),::VertxPgClient::PgPool)
elsif param_1.class.method_defined?(:j_del) && param_2.class == Hash && !block_given?
return ::Vertx::Util::Utils.safe_create(Java::ComJulienvietPgclient::PgClient.java_method(:pool, [Java::IoVertxCore::Vertx.java_class,Java::ComJulienvietPgclient::PgPoolOptions.java_class]).call(param_1.j_del,Java::ComJulienvietPgclient::PgPoolOptions.new(::Vertx::Util::Utils.to_json_object(param_2))),::VertxPgClient::PgPool)
end
raise ArgumentError, "Invalid arguments when calling pool(#{param_1},#{param_2})"
end
# Connects to the database and returns the connection if that succeeds.
#
# The connection interracts directly with the database is not a proxy, so closing the
# connection will close the underlying connection to the database.
# @param [::Vertx::Vertx] vertx the vertx instance
# @param [Hash] options the connect options
# @yield the handler called with the connection or the failure
# @return [void]
def self.connect(vertx=nil,options=nil)
if vertx.class.method_defined?(:j_del) && options.class == Hash && block_given?
return Java::ComJulienvietPgclient::PgClient.java_method(:connect, [Java::IoVertxCore::Vertx.java_class,Java::ComJulienvietPgclient::PgConnectOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(vertx.j_del,Java::ComJulienvietPgclient::PgConnectOptions.new(::Vertx::Util::Utils.to_json_object(options)),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxPgClient::PgConnection) : nil) }))
end
raise ArgumentError, "Invalid arguments when calling connect(#{vertx},#{options})"
end
# Execute a simple query.
# @param [String] sql the query SQL
# @yield the handler notified with the execution result
# @return [self]
def query(sql=nil)
if sql.class == String && block_given?
@j_del.java_method(:query, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxPgClient::PgResult,::VertxPgClient::Row.j_api_type) : nil) }))
return self
end
raise ArgumentError, "Invalid arguments when calling query(#{sql})"
end
# Prepare and execute a query.
# @param [String] sql the prepared query SQL
# @param [::VertxPgClient::Tuple] arguments the list of arguments
# @yield the handler notified with the execution result
# @return [self]
def prepared_query(sql=nil,arguments=nil)
if sql.class == String && block_given? && arguments == nil
@j_del.java_method(:preparedQuery, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxPgClient::PgResult,::VertxPgClient::Row.j_api_type) : nil) }))
return self
elsif sql.class == String && arguments.class.method_defined?(:j_del) && block_given?
@j_del.java_method(:preparedQuery, [Java::java.lang.String.java_class,Java::ComJulienvietPgclient::Tuple.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,arguments.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxPgClient::PgResult,::VertxPgClient::Row.j_api_type) : nil) }))
return self
end
raise ArgumentError, "Invalid arguments when calling prepared_query(#{sql},#{arguments})"
end
# Prepare and execute a createBatch.
# @param [String] sql the prepared query SQL
# @param [Array<::VertxPgClient::Tuple>] batch the batch of tuples
# @yield the handler notified with the execution result
# @return [self]
def prepared_batch(sql=nil,batch=nil)
if sql.class == String && batch.class == Array && block_given?
@j_del.java_method(:preparedBatch, [Java::java.lang.String.java_class,Java::JavaUtil::List.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,batch.map { |element| element.j_del },(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxPgClient::PgResult,::VertxPgClient::Row.j_api_type) : nil) }))
return self
end
raise ArgumentError, "Invalid arguments when calling prepared_batch(#{sql},#{batch})"
end
end
end