module Sequel::TemporarilyReleaseConnection::PoolMethods

  1. lib/sequel/extensions/temporarily_release_connection.rb

Methods

Public Instance

  1. temporarily_release_connection

Public Instance methods

temporarily_release_connection(conn, server)

Temporarily release a currently checked out connection, then yield to the block. Reacquire the same connection upon the exit of the block.

[show source]
   # File lib/sequel/extensions/temporarily_release_connection.rb
75 def temporarily_release_connection(conn, server)
76   t = Sequel.current
77   raise Error, "connection not currently checked out" unless conn.equal?(trc_owned_connection(t, server))
78 
79   begin
80     trc_release(t, conn, server)
81     yield
82   ensure
83     c = trc_acquire(t, server)
84     unless conn.equal?(c)
85       raise UnableToReacquireConnectionError, "reacquired connection not the same as initial connection"
86     end
87   end
88 end