lib/danconia/money.rb in danconia-0.3.0 vs lib/danconia/money.rb in danconia-0.3.1
- old
+ new
@@ -1,11 +1,14 @@
require 'bigdecimal'
require 'danconia/errors/exchange_rate_not_found'
+require 'danconia/serializable'
module Danconia
class Money
include Comparable
+ include Serializable
+
attr_reader :amount, :currency, :decimals
def initialize(amount, currency_code = nil, decimals: 2, exchange_opts: {})
@amount = parse amount
@decimals = decimals
@@ -65,14 +68,10 @@
def in_cents
(self * 100).round
end
- def as_json *args
- amount.as_json *args
- end
-
def default_currency?
currency.code == Danconia.config.default_currency
end
def method_missing method, *args
@@ -81,11 +80,11 @@
else
super
end
end
- def respond_to? method, *args
- super or @amount.respond_to?(method, *args)
+ def respond_to_missing? method, *args
+ @amount.respond_to?(method, *args) || super
end
private
def parse object