Class: Numeric

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo_odm/core_ext/conversions.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) type_cast(value)



234
235
236
237
238
239
# File 'lib/mongo_odm/core_ext/conversions.rb', line 234

def self.type_cast(value)
  return nil if value.nil?
  float_value = value.to_f
  int_value = value.to_i
  float_value == int_value ? int_value : float_value
end