Class: MongoModel::Types::Float

Inherits:
Object
  • Object
show all
Defined in:
lib/mongomodel/support/types/float.rb

Instance Method Summary collapse

Methods inherited from Object

#from_mongo, #to_mongo, #to_query

Instance Method Details

#boolean(value) ⇒ Object


12
13
14
# File 'lib/mongomodel/support/types/float.rb', line 12

def boolean(value)
  !value.zero?
end

#cast(value) ⇒ Object


4
5
6
7
8
9
10
# File 'lib/mongomodel/support/types/float.rb', line 4

def cast(value)
  if value.nil?
    nil
  else
    Kernel::Float(value) rescue nil
  end
end