Class: ActiveRecordCompose::TransactionSupport::ActiveTransaction
- Inherits:
-
Object
- Object
- ActiveRecordCompose::TransactionSupport::ActiveTransaction
- Defined in:
- lib/active_record_compose/transaction_support/active_transaction.rb
Overview
In older versions, the ActiveRecord::Transaction object is not passed to the block argument of #transaction. So instead, we define a transaction object that can be evaluated equivalently. This follow-up will no longer be necessary when support for Rails 7.1 is dropped.
Instance Attribute Summary collapse
-
#real_transaction ⇒ void
readonly
Returns the value of attribute real_transaction.
Instance Method Summary collapse
- #==(other) ⇒ void
- #closed? ⇒ Boolean
- #eql?(other) ⇒ Boolean
- #hash ⇒ void
-
#initialize(transaction) ⇒ ActiveTransaction
constructor
A new instance of ActiveTransaction.
- #open? ⇒ Boolean
Constructor Details
#initialize(transaction) ⇒ ActiveTransaction
Returns a new instance of ActiveTransaction.
13 14 15 |
# File 'lib/active_record_compose/transaction_support/active_transaction.rb', line 13 def initialize(transaction) @real_transaction = transaction end |
Instance Attribute Details
#real_transaction ⇒ void (readonly)
Returns the value of attribute real_transaction.
17 18 19 |
# File 'lib/active_record_compose/transaction_support/active_transaction.rb', line 17 def real_transaction @real_transaction end |
Instance Method Details
#==(other) ⇒ void
23 24 25 26 27 28 |
# File 'lib/active_record_compose/transaction_support/active_transaction.rb', line 23 def ==(other) return true if equal?(other) return false unless self.class == other.class real_transaction == other.real_transaction end |
#closed? ⇒ Boolean
21 |
# File 'lib/active_record_compose/transaction_support/active_transaction.rb', line 21 def closed? = real_transaction&.state&.completed? |
#eql?(other) ⇒ Boolean
30 31 32 33 34 35 |
# File 'lib/active_record_compose/transaction_support/active_transaction.rb', line 30 def eql?(other) return true if equal?(other) return false unless self.class == other.class real_transaction.eql?(other.real_transaction) end |
#hash ⇒ void
37 |
# File 'lib/active_record_compose/transaction_support/active_transaction.rb', line 37 def hash = real_transaction.hash |
#open? ⇒ Boolean
19 |
# File 'lib/active_record_compose/transaction_support/active_transaction.rb', line 19 def open? = !closed? |