Class: Mongoid::Fields::Money

Inherits:
Object
  • Object
show all
Includes:
Serializable
Defined in:
lib/money/mongoid/2x/money.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.instantiate(name, options = {}) ⇒ Object



9
10
11
# File 'lib/money/mongoid/2x/money.rb', line 9

def self.instantiate(name, options = {})
  super
end

Instance Method Details

#deserialize(value) ⇒ Object



13
14
15
# File 'lib/money/mongoid/2x/money.rb', line 13

def deserialize(value)
  ::Money.new value[:cents], value[:currency_iso]
end

#serialize(value) ⇒ Object



17
18
19
# File 'lib/money/mongoid/2x/money.rb', line 17

def serialize(value)
  {:cents => value.cents, :currency_iso => value.currency.iso_code}
end