-
-
Save dcyoung-dev/1519fbd8795171089aaaf9c0e6fcab8c to your computer and use it in GitHub Desktop.
This file contains 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 Loan | |
attr_accessor :outstanding_balance, :remaining_months, :monthly_repayments | |
def save! | |
end | |
end | |
def some_calculation | |
10 | |
end | |
def make_change(loan:, &block) | |
yield loan if block_given? | |
loan.monthly_repayments = some_calculation | |
loan.save | |
end | |
new_loan = Loan.new | |
make_change(loan: new_loan) do |yielded_loan| | |
yielded_loan.outstanding_balance = 100_00 | |
end | |
make_change(loan: new_loan) do |yielded_loan| | |
yielded_loan.remaining_months = 100 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment