Memoize OrderBalance instance

There's no need to create an instance of such class for every call to
one of its methods. The balance is computed each time anyway, so it'll
always be up-to-date.
This commit is contained in:
Pau Perez
2021-04-14 12:00:59 +02:00
parent 5bca7d1f8f
commit d26c52c2fa

View File

@@ -9,7 +9,7 @@ module Balance
# Branches by the OrderBalance abstraction
def outstanding_balance
OrderBalance.new(self)
@order_balance ||= OrderBalance.new(self)
end
# Returns the order balance by considering the total as money owed to the order distributor aka.