Method: Sequel::Database#synchronize
- Defined in:
- lib/sequel/database/connecting.rb
#synchronize(server = nil, &block) ⇒ Object
Acquires a database connection, yielding it to the passed block. This is useful if you want to make sure the same connection is used for all database queries in the block. It is also useful if you want to gain direct access to the underlying connection object if you need to do something Sequel does not natively support.
If a server option is given, acquires a connection for that specific server, instead of the :default server.
DB.synchronize do |conn|
# ...
end
282 283 284 |
# File 'lib/sequel/database/connecting.rb', line 282 def synchronize(server=nil, &block) @pool.hold(server || :default, &block) end |