Permalink
Browse files

patch for #issue/12, Numeric#to_money should respect :subunit_to_unit

  • Loading branch information...
semmons99 committed Jul 12, 2010
1 parent 106b6b1 commit fe5cb0302c00eff465d3d5940d5b56bb3e9f52dd
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/money/core_extensions.rb
@@ -7,7 +7,8 @@ class Numeric
# require 'bigdecimal'
# BigDecimal.new('100').to_money => #<Money @cents=10000>
def to_money(currency = Money.default_currency)
- Money.new((self * 100).to_int, currency)
+ currency = Money::Currency.new(currency) unless currency.is_a?(Money::Currency)
+ Money.new((self * currency.subunit_to_unit).to_int, currency)
end
end

0 comments on commit fe5cb03

Please sign in to comment.