Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Always commit or rollback an transaction. Previous code only handled Ruby #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions lib/dm-transactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,13 @@ def commit
begin
self.begin
rval = within { |*block_args| yield(*block_args) }
rescue Exception => exception
if begin?
rollback
end
raise exception
commit
complete = true
ensure
unless exception
if begin?
commit
end
return rval
end
rollback unless complete
end

rval
else
unless begin?
raise "Illegal state for commit without block: #{state}"
Expand Down