Skip to content

Instantly share code, notes, and snippets.

@sprite2005
Created February 17, 2009 05:46
Show Gist options
  • Save sprite2005/65597 to your computer and use it in GitHub Desktop.
Save sprite2005/65597 to your computer and use it in GitHub Desktop.
def update_balance
calculated_balance = Money.new(0)
sent_transactions.each do |transaction|
calculated_balance += transaction.sender_amount
end
received_transactions.each do |transaction|
calculated_balance += transaction.receiver_amount
end
self.balance = calculated_balance
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment