Method: WithConnection::ConnectionPool#with_connection

Defined in:
lib/with_connection/connection_pool.rb

#with_connection(key = nil, read_write = nil) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/with_connection/connection_pool.rb', line 19

def with_connection(key=nil, read_write=nil)
  connection_id = current_connection_id
  fresh_connection = true unless @reserved_connections[connection_id]
  yield connection
ensure
  release_connection(connection_id) if fresh_connection
end