Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

DRY

  • Loading branch information...
commit dd48f0ea4c9f83357c348a5f4ddd5b09ecfb23f2 1 parent 58ced30
@jonleighton jonleighton authored
View
12 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
@@ -180,14 +180,14 @@ def transaction(options = {})
begin
if @transaction.closed? || requires_new
- @transaction = @transaction.begin
+ begin_transaction
transaction_open = true
end
yield
rescue Exception => error
if !outside_transaction? && transaction_open
- @transaction = @transaction.rollback
+ rollback_transaction
transaction_open = false
end
@@ -201,9 +201,9 @@ def transaction(options = {})
@transaction = Transactions::Closed.new(self)
elsif @transaction.open? && transaction_open
begin
- @transaction = @transaction.commit
+ commit_transaction
rescue Exception
- @transaction = @transaction.rollback
+ rollback_transaction
raise
end
end
@@ -217,6 +217,10 @@ def begin_transaction #:nodoc:
@transaction = @transaction.begin
end
+ def commit_transaction #:nodoc:
+ @transaction = @transaction.commit
+ end
+
def rollback_transaction #:nodoc:
@transaction = @transaction.rollback
end
Please sign in to comment.
Something went wrong with that request. Please try again.