Created
September 10, 2015 21:11
-
-
Save dpaola2/5e07a1efd44bad662f4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Account | |
... | |
end | |
class Transfer | |
def self.exec(acct1, acct2, amt) | |
Transaction.begin do | |
acct1.balance -= amt | |
acct2.balance += amt | |
acct1.save! | |
acct2.save! | |
end | |
end | |
end | |
Transfer.exec(Account.find(1), Account.find(2), 500.00) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment