Class: ActiveRecord::ConnectionAdapters::TransactionState
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::TransactionState
show all
- Defined in:
- lib/active_record/connection_adapters/abstract/transaction.rb
Overview
Active Record Connection Adapters Transaction State
Instance Method Summary
collapse
Constructor Details
Returns a new instance of TransactionState.
9
10
11
12
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 9
def initialize(state = nil)
@state = state
@children = nil
end
|
Instance Method Details
#add_child(state) ⇒ Object
14
15
16
17
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 14
def add_child(state)
@children ||= []
@children << state
end
|
#commit! ⇒ Object
66
67
68
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 66
def commit!
@state = :committed
end
|
#committed? ⇒ Boolean
23
24
25
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 23
def committed?
@state == :committed || @state == :fully_committed
end
|
#completed? ⇒ Boolean
47
48
49
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 47
def completed?
committed? || rolledback?
end
|
#finalized? ⇒ Boolean
19
20
21
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 19
def finalized?
@state
end
|
#full_commit! ⇒ Object
70
71
72
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 70
def full_commit!
@state = :fully_committed
end
|
#full_rollback! ⇒ Object
56
57
58
59
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 56
def full_rollback!
@children&.each { |c| c.rollback! }
@state = :fully_rolledback
end
|
#fully_committed? ⇒ Boolean
27
28
29
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 27
def fully_committed?
@state == :fully_committed
end
|
#fully_completed? ⇒ Boolean
43
44
45
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 43
def fully_completed?
completed?
end
|
#fully_rolledback? ⇒ Boolean
35
36
37
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 35
def fully_rolledback?
@state == :fully_rolledback
end
|
#invalidate! ⇒ Object
61
62
63
64
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 61
def invalidate!
@children&.each { |c| c.invalidate! }
@state = :invalidated
end
|
#invalidated? ⇒ Boolean
39
40
41
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 39
def invalidated?
@state == :invalidated
end
|
#nullify! ⇒ Object
74
75
76
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 74
def nullify!
@state = nil
end
|
#rollback! ⇒ Object
51
52
53
54
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 51
def rollback!
@children&.each { |c| c.rollback! }
@state = :rolledback
end
|
#rolledback? ⇒ Boolean
31
32
33
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 31
def rolledback?
@state == :rolledback || @state == :fully_rolledback
end
|