Last active
August 23, 2019 11:22
-
-
Save KelseyDH/2214aa4da127f512e038be5fd3d70a33 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
# app/domain/null_account.rb | |
class NullAccount | |
def id | |
raise "You are calling id on an account that doesn't exist. Make sure the user you're working with has accounts first before trying to call them." | |
end | |
def available_balance | |
Money.new(available_balance_cents, available_balance_currency) | |
end | |
def available_balance_cents | |
0 | |
end | |
def available_balance_currency | |
"CAD" | |
end | |
def valid? | |
false | |
end | |
def present? | |
false | |
end | |
def blank? | |
true | |
end | |
def account_key | |
raise "account_key is being called on a NullAccount!!" | |
end | |
def currency | |
"CAD" | |
end | |
def save | |
raise ActiveRecord::RecordInvalid | |
end | |
def update | |
raise ActiveRecord::RecordInvalid | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment