123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::ConnectionAdapters::TransactionState

Relationships & Source Files
Inherits: Object
Defined in: activerecord/lib/active_record/connection_adapters/abstract/transaction.rb

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(state = nil) ⇒ TransactionState

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 8

def initialize(state = nil)
  @state = state
  @parent = nil
end

Instance Attribute Details

#committed?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 17

def committed?
  @state == :committed
end

#completed?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 25

def completed?
  committed? || rolledback?
end

#finalized?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 13

def finalized?
  @state
end

#parent (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 4

attr_reader :parent

#rolledback?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 21

def rolledback?
  @state == :rolledback
end

Instance Method Details

#set_state(state)

[ GitHub ]

  
# File 'activerecord/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