class ActiveRecord::ConnectionAdapters::TransactionState
Active Record Connection Adapters Transaction State
Public class methods
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 7
def initialize(state = nil)
@state = state
@children = nil
end
Public instance methods
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 12
def add_child(state)
@children ||= []
@children << state
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 64
def commit!
@state = :committed
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 21
def committed?
@state == :committed || @state == :fully_committed
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 45
def completed?
committed? || rolledback?
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 17
def finalized?
@state
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 68
def full_commit!
@state = :fully_committed
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 54
def full_rollback!
@children&.each { |c| c.rollback! }
@state = :fully_rolledback
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 25
def fully_committed?
@state == :fully_committed
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 41
def fully_completed?
completed?
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 33
def fully_rolledback?
@state == :fully_rolledback
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 59
def invalidate!
@children&.each { |c| c.invalidate! }
@state = :invalidated
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 37
def invalidated?
@state == :invalidated
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 72
def nullify!
@state = nil
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 49
def rollback!
@children&.each { |c| c.rollback! }
@state = :rolledback
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 29
def rolledback?
@state == :rolledback || @state == :fully_rolledback
end