Class: Integer

Inherits:
Object show all
Defined in:
lib/mongo_mapper/extensions.rb

Class Method Summary collapse

Class Method Details

.to_mongo(value) ⇒ Object



80
81
82
83
84
85
86
87
# File 'lib/mongo_mapper/extensions.rb', line 80

def self.to_mongo(value)
  value_to_i = value.to_i
  if value_to_i == 0 && value != value_to_i
    value.to_s =~ /^(0x|0b)?0+/ ? 0 : nil
  else
    value_to_i
  end
end