class Sequel::SingleConnectionPool

  1. lib/sequel/connection_pool/single.rb
Parent: Sequel

This is the fastest connection pool, since it isn't a connection pool at all. It is just a wrapper around a single connection that uses the connection pool API.

Methods

Public Instance

  1. all_connections
  2. disconnect
  3. hold
  4. size

Public Instance methods

all_connections ()

Yield the connection if one has been made.

[show source]
# File lib/sequel/connection_pool/single.rb, line 12
def all_connections
  yield @conn if @conn
end
disconnect (opts=nil, &block)

Disconnect the connection from the database.

[show source]
# File lib/sequel/connection_pool/single.rb, line 17
def disconnect(opts=nil, &block)
  return unless @conn
  block ||= @disconnection_proc
  block.call(@conn) if block
  @conn = nil
end
hold (server=nil)

Yield the connection to the block.

[show source]
# File lib/sequel/connection_pool/single.rb, line 25
def hold(server=nil)
  begin
    yield(@conn ||= make_new(DEFAULT_SERVER))
  rescue Sequel::DatabaseDisconnectError
    disconnect
    raise
  end
end
size ()

The SingleConnectionPool always has a size of 1 if connected and 0 if not.

[show source]
# File lib/sequel/connection_pool/single.rb, line 7
def size
  @conn ? 1 : 0
end