Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit fe5cb0302c00eff465d3d5940d5b56bb3e9f52dd 1 parent 106b6b1
@semmons99 semmons99 authored
Showing with 2 additions and 1 deletion.
  1. +2 −1  lib/money/core_extensions.rb
View
3  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
Please sign in to comment.
Something went wrong with that request. Please try again.