add Database#using_connection to get a connection from the pool and return it when work is done.
This commit is contained in:
parent
22db7d1043
commit
f836bbfccb
|
@ -45,6 +45,16 @@ module DB
|
|||
@in_pool = true
|
||||
end
|
||||
|
||||
# yields a connection from the pool
|
||||
# the connection is returned to the pool after
|
||||
# when the block ends
|
||||
def using_connection
|
||||
connection = get_from_pool
|
||||
yield connection
|
||||
ensure
|
||||
return_to_pool connection
|
||||
end
|
||||
|
||||
include QueryMethods
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue