Module: TorqueBox::Transactions::ActiveRecordAdapters::Transaction

Included in:
Manager
Defined in:
transactions/lib/torquebox/active_record_adapters.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) commit

Raises:

  • (ActiveRecord::Rollback)


87
88
89
90
91
92
# File 'transactions/lib/torquebox/active_record_adapters.rb', line 87

def commit
  raise ActiveRecord::Rollback if @rolled_back
  super
  @complete = true
  connections.each { |connection| connection.commit_transaction_records }
end

- (Object) connections



115
116
117
# File 'transactions/lib/torquebox/active_record_adapters.rb', line 115

def connections
  @connections ||= Set.new
end

- (Object) error(exception)



82
83
84
85
# File 'transactions/lib/torquebox/active_record_adapters.rb', line 82

def error( exception )
  super
rescue ActiveRecord::Rollback
end

- (Object) prepare



75
76
77
78
79
80
# File 'transactions/lib/torquebox/active_record_adapters.rb', line 75

def prepare
  super
  # TODO: not this, but we need AR's pooled connection to
  # refresh from jboss *after* the transaction is begun.
  ActiveRecord::Base.clear_active_connections!
end

- (Object) rollback



94
95
96
97
98
99
100
# File 'transactions/lib/torquebox/active_record_adapters.rb', line 94

def rollback
  super
  @complete = true
  connections.each do |connection| 
    connection.rollback_transaction_records(@transactions.empty?) 
  end
end

- (Boolean) should_commit?(connection)

Returns:

  • (Boolean)


102
103
104
105
106
# File 'transactions/lib/torquebox/active_record_adapters.rb', line 102

def should_commit?(connection)
  return true if @complete || !active?
  connections << connection
  false
end

- (Boolean) should_rollback?(connection)

Returns:

  • (Boolean)


108
109
110
111
112
113
# File 'transactions/lib/torquebox/active_record_adapters.rb', line 108

def should_rollback?(connection)
  return true if @complete || !active?
  connections << connection
  @rolled_back = true
  false
end