All Downloads are FREE. Search and download functionalities are using the official Maven repository.

vertx-pg-client.pg_transaction.rb Maven / Gradle / Ivy

require 'vertx/util/utils.rb'
# Generated from com.julienviet.pgclient.PgTransaction
module VertxPgClient
  #  A transaction that allows to control the transaction and receive events.
  class PgTransaction
    # @private
    # @param j_del [::VertxPgClient::PgTransaction] the java delegate
    def initialize(j_del)
      @j_del = j_del
    end
    # @private
    # @return [::VertxPgClient::PgTransaction] the underlying java delegate
    def j_del
      @j_del
    end
    @@j_api_type = Object.new
    def @@j_api_type.accept?(obj)
      obj.class == PgTransaction
    end
    def @@j_api_type.wrap(obj)
      PgTransaction.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::PgTransaction.java_class
    end
    #  Like {::VertxPgClient::PgTransaction#commit} with an handler to be notified when the transaction commit has completed
    # @yield 
    # @return [void]
    def commit
      if !block_given?
        return @j_del.java_method(:commit, []).call()
      elsif block_given?
        return @j_del.java_method(:commit, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling commit()"
    end
    #  Like {::VertxPgClient::PgTransaction#rollback} with an handler to be notified when the transaction rollback has completed
    # @yield 
    # @return [void]
    def rollback
      if !block_given?
        return @j_del.java_method(:rollback, []).call()
      elsif block_given?
        return @j_del.java_method(:rollback, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling rollback()"
    end
    #  Set an handler to be called when the transaction is aborted.
    # @yield the handler
    # @return [self]
    def abort_handler
      if block_given?
        @j_del.java_method(:abortHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield })
        return self
      end
      raise ArgumentError, "Invalid arguments when calling abort_handler()"
    end
  end
end




© 2015 - 2024 Weber Informatics LLC | Privacy Policy