Class: Sequel::ConnectionPool

Inherits:
Object
  • Object
show all
Defined in:
lib/sequelizer/monkey_patches/database_in_after_connect.rb

Instance Method Summary collapse

Instance Method Details

#make_new(server) ⇒ Object

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

Raises:

  • (Sequel::DatabaseConnectionError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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