-
Notifications
You must be signed in to change notification settings - Fork 634
Deprecate Money#dollars
and Money.from_dollars
#1153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Deprecate Money#dollars
and Money.from_dollars
#1153
Conversation
lib/money/money.rb
Outdated
# | ||
# Synonym of #amount | ||
# | ||
# @return [BigDecimal] | ||
# | ||
# @example | ||
# Money.new(1_00, "USD").dollars # => BigDecimal("1.00") | ||
# Money.new(1_00, "USD").dollars # => BigDecimal("1.00") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve included a few minor whitespace fixes to harmonize the documentation format.
expect(currency).to receive(:symbol).and_return("€") | ||
expect(Money.new(0, currency).symbol).to eq "€" | ||
it "returns the currency’s symbol" do | ||
expect(Money.new(0, "EUR").symbol).to eq("€") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor simplification for this test so as not to rely on stubs so much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd go as far as to deprecate the method itself, regardless of the currency used. It's US-centric and potentially confusing as to, why this de-facto alias of |
Good call. It also doesn’t raise any error if the default currency is not dollars-based. Money.default_currency = "EUR"
Money.from_dollars(13) # => 13 EUR 🙃 However, the change is rather recent. #1032
I’d tend to agree, the I’ll deprecate all the |
Money#dollars
when the currency is not USDMoney#dollars
and Money.from_dollar
Money#dollars
and Money.from_dollar
Money#dollars
and Money.from_dollars
The
#dollars
method assumes the amount is inUSD
but does nothing to verify that.I would like to add a warning to let people know that something is wrong here and so that in the future we can actually raise an error here.Edit: Calling
#dollars
and.from_dollars
are both now deprecated in favor of#amount
and.from_amount
.