Class: ActiveRecord::ConnectionAdapters::TransactionState
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::TransactionState
- Defined in:
- lib/active_record/connection_adapters/abstract/transaction.rb
Instance Method Summary collapse
- #add_child(state) ⇒ Object
- #commit! ⇒ Object
- #committed? ⇒ Boolean
- #completed? ⇒ Boolean
- #finalized? ⇒ Boolean
- #full_commit! ⇒ Object
- #full_rollback! ⇒ Object
- #fully_committed? ⇒ Boolean
- #fully_completed? ⇒ Boolean
- #fully_rolledback? ⇒ Boolean
-
#initialize(state = nil) ⇒ TransactionState
constructor
A new instance of TransactionState.
- #nullify! ⇒ Object
- #rollback! ⇒ Object
- #rolledback? ⇒ Boolean
Constructor Details
#initialize(state = nil) ⇒ TransactionState
Returns a new instance of TransactionState.
6 7 8 9 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 6 def initialize(state = nil) @state = state @children = [] end |
Instance Method Details
#add_child(state) ⇒ Object
11 12 13 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 11 def add_child(state) @children << state end |
#commit! ⇒ Object
53 54 55 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 53 def commit! @state = :committed end |
#committed? ⇒ Boolean
19 20 21 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 19 def committed? @state == :committed || @state == :fully_committed end |
#completed? ⇒ Boolean
39 40 41 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 39 def completed? committed? || rolledback? end |
#finalized? ⇒ Boolean
15 16 17 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 15 def finalized? @state end |
#full_commit! ⇒ Object
57 58 59 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 57 def full_commit! @state = :fully_committed end |
#full_rollback! ⇒ Object
48 49 50 51 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 48 def full_rollback! @children.each { |c| c.rollback! } @state = :fully_rolledback end |
#fully_committed? ⇒ Boolean
23 24 25 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 23 def fully_committed? @state == :fully_committed end |
#fully_completed? ⇒ Boolean
35 36 37 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 35 def fully_completed? completed? end |
#fully_rolledback? ⇒ Boolean
31 32 33 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 31 def fully_rolledback? @state == :fully_rolledback end |
#nullify! ⇒ Object
61 62 63 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 61 def nullify! @state = nil end |
#rollback! ⇒ Object
43 44 45 46 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 43 def rollback! @children.each { |c| c.rollback! } @state = :rolledback end |
#rolledback? ⇒ Boolean
27 28 29 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 27 def rolledback? @state == :rolledback || @state == :fully_rolledback end |