Skip to content

Commit

Permalink
support ActiveRecord::Base#lease_connection
Browse files Browse the repository at this point in the history
  • Loading branch information
hamajyotan committed Mar 16, 2024
1 parent 14eebd5 commit 0b0e8d9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## [Unreleased]

- purge nodoc definitions from type signature
- support `ActiveRecord::Base#lease_connection`

## [0.3.0] - 2024-02-24

Expand Down
8 changes: 8 additions & 0 deletions lib/active_record_compose/transaction_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ module TransactionSupport
include ActiveRecord::Transactions

module ClassMethods
def lease_connection
if ActiveRecord::Base.respond_to?(:lease_connection)
__skip__ = ActiveRecord::Base.lease_connection
else
ActiveRecord::Base.connection
end
end

def connection = ActiveRecord::Base.connection

def composite_primary_key? = false
Expand Down
1 change: 1 addition & 0 deletions sig/active_record_compose.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ module ActiveRecordCompose

module ClassMethods
def connection: -> ActiveRecord::ConnectionAdapters::AbstractAdapter
def lease_connection: -> ActiveRecord::ConnectionAdapters::AbstractAdapter
end
end
end

0 comments on commit 0b0e8d9

Please sign in to comment.