Module: Mongoid::Extensions::Money::Conversions

Included in:
Money
Defined in:
lib/mongoid_money/conversions.rb

Instance Method Summary collapse

Instance Method Details

#get(value) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/mongoid_money/conversions.rb', line 13

def get(value)
  return nil if value.blank?
  begin
    self.new_from_cents value
  rescue
    nil
  end
end

#set(value) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/mongoid_money/conversions.rb', line 5

def set(value)
  return nil if value.blank?
  begin
    value.cents
  rescue
    value
  end
end