In an initializer add the following
Money.configure do |config|
config.legacy_default_currency!
config.legacy_deprecations!
config.legacy_json_format!
#...
end
Remove each legacy setting making sure your app functions as expected.
Replace Money.parse
with Money::Parser::Fuzzy.parse
.
By enabling this setting your app will accept money object that are missing a currency
Money.new(1) #=> value: 1, currency: XXX
invalid money values return zero
Money.new('a', 'USD') #=> Money.new(0, 'USD')
invalid currency is ignored
Money.new(1, 'ABCD') #=> Money.new(1)
mathematical operations between objects are allowed
Money.new(1, 'USD') + Money.new(1, 'CAD') #=> Money.new(2, 'USD')
parsing a string with invalid delimiters
Money.parse('123*12') #=> Money.new(123)
to_json will return only the value (no currency)
# with legacy_json_format!
money.to_json #=> "1"
# without
money.to_json #=> { value: 1, currency: 'USD' }