Class: ActiveRecord::ConnectionAdapters::TransactionState
- Defined in:
- activerecord/lib/active_record/connection_adapters/abstract/transaction.rb
Constant Summary collapse
- VALID_STATES =
Set.new([:committed, :rolledback, nil])
Instance Attribute Summary collapse
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #committed? ⇒ Boolean
- #finalized? ⇒ Boolean
-
#initialize(state = nil) ⇒ TransactionState
constructor
A new instance of TransactionState.
- #rolledback? ⇒ Boolean
- #set_state(state) ⇒ Object
Constructor Details
#initialize(state = nil) ⇒ TransactionState
Returns a new instance of TransactionState.
21 22 23 24 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 21 def initialize(state = nil) @state = state @parent = nil end |
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent
17 18 19 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 17 def parent @parent end |
Instance Method Details
#committed? ⇒ Boolean
30 31 32 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 30 def committed? @state == :committed end |
#finalized? ⇒ Boolean
26 27 28 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 26 def finalized? @state end |
#rolledback? ⇒ Boolean
34 35 36 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 34 def rolledback? @state == :rolledback end |
#set_state(state) ⇒ Object
38 39 40 41 42 43 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 38 def set_state(state) if !VALID_STATES.include?(state) raise ArgumentError, "Invalid transaction state: #{state}" end @state = state end |