class Sequel::ConnectionPool

Public Instance Methods

make_new(server) click to toggle source

Return a new connection by calling the connection proc with the given server name, and checking for connection errors.

# File lib/sequelizer/monkey_patches/database_in_after_connect.rb, line 5
def make_new(server)
  begin
    conn = @db.connect(server)
    if ac = @after_connect
      case ac.arity
      when 3
        ac.call(conn, server, @db)
      when 2
        ac.call(conn, server)
      else
        ac.call(conn)
      end
    end
  rescue Exception=>exception
    raise Sequel.convert_exception_class(exception, Sequel::DatabaseConnectionError)
  end
  raise(Sequel::DatabaseConnectionError, "Connection parameters not valid") unless conn
  conn
end