exc/rollback |
class Rollback < Object |
Public Methods |
Create a new Rollback object. You should generally not have to do this directly; use Rollback::rollback() instead.
Specify that the passed proc or method should be called when an exception occurs. All undo actions will be called in the reverse order in which they were created.
Run the passed block, and call the given undo() actions in reverse order if an exception occurs. The exception will be properly propogated to the caller.
E.g.:
Rollback::rollback do |rb, *args| rb.undo(Proc.new { puts "1" }) rb.undo(Proc.new { puts "2" }) rb.undo(Proc.new { puts "3" }) raise RuntimeError end