Rolling back changes (cont'd) Solution: 1 class UserDB 2 def adduser(username, password, address, phone) 3 rollback = [] 4 begin 5 @phone_db.adduser(username, address, phone) 6 rollback.push proc { @phone_db.deluser(username) } 7 @system1_db.adduser(username, password) 8 rollback.push proc { @system1_db.deluser(username) } 9 @system2_db.adduser(username, password) 10 rollback.clear 11 ensure 12 rollback.reverse_each { |p| p.call } 13 end 14 end 15 end