Skip to content

Commit

Permalink
Convert the fractional value of a Money object to BigDecimal when ini…
Browse files Browse the repository at this point in the history
…tializing
  • Loading branch information
antstorm committed Nov 8, 2018
1 parent 5626e4c commit b82492c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/money/money.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def self.from_amount(amount, currency = default_currency, bank = default_bank)
# Money.new(100, "EUR") #=> #<Money @fractional=100 @currency="EUR">
#
def initialize(obj, currency = Money.default_currency, bank = Money.default_bank)
@fractional = obj.respond_to?(:fractional) ? obj.fractional : as_d(obj)
@fractional = as_d(obj.respond_to?(:fractional) ? obj.fractional : obj)
@currency = obj.respond_to?(:currency) ? obj.currency : Currency.wrap(currency)
@currency ||= Money.default_currency
@bank = obj.respond_to?(:bank) ? obj.bank : bank
Expand Down

0 comments on commit b82492c

Please sign in to comment.