Skip to content

Commit

Permalink
Remove Ruby <2.5 optimized Database#synchronize method
Browse files Browse the repository at this point in the history
Sequel supports old Ruby versions in order to make it
easier to transition applications from old Ruby versions
to modern Ruby versions, but there is no reason to support
optimized versions of methods for old Ruby versions.
  • Loading branch information
jeremyevans committed Jun 5, 2024
1 parent d4978ea commit 52ccf07
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions lib/sequel/database/connecting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,28 +270,20 @@ def single_threaded?
@single_threaded
end

if RUBY_ENGINE == 'ruby' && RUBY_VERSION < '2.5'
# :nocov:
def synchronize(server=nil)
@pool.hold(server || :default){|conn| yield conn}
end
# :nocov:
else
# 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
def synchronize(server=nil, &block)
@pool.hold(server || :default, &block)
end
# 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
def synchronize(server=nil, &block)
@pool.hold(server || :default, &block)
end

# Attempts to acquire a database connection. Returns true if successful.
Expand Down

0 comments on commit 52ccf07

Please sign in to comment.