Sha256: 8586005257fe3aef7ccb879f77d3a001f681809d3061f909b4ff93f58aa63445

Contents?: true

Size: 518 Bytes

Versions: 5

Compression:

Stored size: 518 Bytes

Contents

# Allows Writing of 100.to_money for +Numeric+ types
#   100.to_money => #<Money @cents=10000>
#   100.37.to_money => #<Money @cents=10037>
class Numeric
  def to_money(currency = nil)
    Money.new(self, currency)
  end
end

# Allows Writing of '100'.to_money for +String+ types
# Excess characters will be discarded
#   '100'.to_money => #<Money @cents=10000>
#   '100.37'.to_money => #<Money @cents=10037>
class String
  def to_money(currency = nil)
    empty? ? Money.empty : Money.parse(self, currency)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
shopify-money-0.11.3 lib/money/core_extensions.rb
shopify-money-0.11.2 lib/money/core_extensions.rb
shopify-money-0.11.1 lib/money/core_extensions.rb
shopify-money-0.11.0 lib/money/core_extensions.rb
shopify-money-0.10.0 lib/money/core_extensions.rb