-
-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use
with_connection
where possible (#441)
rails/rails#51349 - this allows rails 7.2 applications to raise an error or emit a deprecation warning whenever `ActiveRecord::Base.connection` is used. this makes sure that in rails 7.1 and after we use the new, preferred method.
- Loading branch information
1 parent
07f6c27
commit 608cca2
Showing
4 changed files
with
59 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 15 additions & 15 deletions
30
lib/acts_as_list/active_record/acts/sequential_updates_method_definer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module ActiveRecord | ||
module Acts | ||
module List | ||
class WithConnection | ||
def initialize(recipient) | ||
@recipient = recipient | ||
end | ||
|
||
attr_reader :recipient | ||
|
||
def call | ||
if recipient.respond_to?(:with_connection) | ||
recipient.with_connection do |connection| | ||
yield connection | ||
end | ||
else | ||
yield recipient.connection | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |