Class: ActiveRecord::ConnectionAdapters::TransactionState
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::TransactionState
- Defined in:
- lib/active_record/connection_adapters/abstract/transaction.rb
Constant Summary collapse
- VALID_STATES =
Set.new([:committed, :rolledback, nil])
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #committed? ⇒ Boolean
- #completed? ⇒ 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.
8 9 10 11 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 8 def initialize(state = nil) @state = state @parent = nil end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
4 5 6 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 4 def parent @parent end |
Instance Method Details
#committed? ⇒ Boolean
17 18 19 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 17 def committed? @state == :committed end |
#completed? ⇒ Boolean
25 26 27 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 25 def completed? committed? || rolledback? end |
#finalized? ⇒ Boolean
13 14 15 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 13 def finalized? @state end |
#rolledback? ⇒ Boolean
21 22 23 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 21 def rolledback? @state == :rolledback end |
#set_state(state) ⇒ Object
29 30 31 32 33 34 |
# File '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 |