Sha256: 1b0ea1a5fede403af9d61711ddf57402722811e13529794444758c8bb967ea4b

Contents?: true

Size: 433 Bytes

Versions: 2

Compression:

Stored size: 433 Bytes

Contents

module Danconia
  module Serializable
    def marshal_dump
      {amount: @amount, currency: @currency.code, decimals: @decimals}
    end

    def marshal_load serialized_money
      @amount = serialized_money[:amount]
      @currency = Currency.find(serialized_money[:currency])
      @decimals = serialized_money[:decimals]
    end

    def as_json _options = {}
      {amount: @amount, currency: @currency.code}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
danconia-0.4.0 lib/danconia/serializable.rb
danconia-0.3.1 lib/danconia/serializable.rb