Class: ActiveRecord::ConnectionAdapters::TransactionState
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activerecord/lib/active_record/connection_adapters/abstract/transaction.rb |
Constant Summary
-
VALID_STATES =
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 6Set.new([:committed, :rolledback, nil])
Class Method Summary
- .new(state = nil) ⇒ TransactionState constructor
Instance Attribute Summary
- #committed? ⇒ Boolean readonly
- #completed? ⇒ Boolean readonly
- #finalized? ⇒ Boolean readonly
- #parent readonly
- #rolledback? ⇒ Boolean readonly
Instance Method Summary
Constructor Details
.new(state = nil) ⇒ TransactionState
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 8
def initialize(state = nil) @state = state @parent = nil end
Instance Attribute Details
#committed? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 17
def committed? @state == :committed end
#completed? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 25
def completed? committed? || rolledback? end
#finalized? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 13
def finalized? @state end
#parent (readonly)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 4
attr_reader :parent
#rolledback? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 21
def rolledback? @state == :rolledback end
Instance Method Details
#set_state(state)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 29
def set_state(state) if !VALID_STATES.include?(state) raise ArgumentError, "Invalid transaction state: #{state}" end @state = state end