add Database#using_connection to get a connection from the pool and return it when work is done.

This commit is contained in:
Brian J. Cardiff 2016-06-23 17:27:30 -03:00
parent 22db7d1043
commit f836bbfccb

View file

@ -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