Class: Money

Inherits:
Object
  • Object
show all
Defined in:
lib/mongomodel/money.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cast(dollars) ⇒ Object



12
13
14
# File 'lib/mongomodel/money.rb', line 12

def self.cast(dollars)
  parse(dollars) unless dollars.blank?
end

.from_mongo(cents) ⇒ Object



8
9
10
# File 'lib/mongomodel/money.rb', line 8

def self.from_mongo(cents)
  new(cents.to_i)
end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/mongomodel/money.rb', line 16

def blank?
  zero?
end

#to_mongoObject



4
5
6
# File 'lib/mongomodel/money.rb', line 4

def to_mongo
  cents
end