Sha256: 9a2bc6ccc1756468738b0606882e2fe3dbc62ce886d10be74cc56d4c2433ec4d

Contents?: true

Size: 366 Bytes

Versions: 71

Compression:

Stored size: 366 Bytes

Contents

# encoding: UTF-8
module MongoMapper
  module Extensions
    module Integer
      def 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
    end
  end
end

class Integer
  extend MongoMapper::Extensions::Integer
end

Version data entries

71 entries across 71 versions & 9 rubygems

Version Path
mongo_mapper-0.12.0 lib/mongo_mapper/extensions/integer.rb
lookout-mongo_mapper-0.11.3 lib/mongo_mapper/extensions/integer.rb
mongo_mapper-0.11.2 lib/mongo_mapper/extensions/integer.rb
jamieorc-mongo_mapper-0.11.1.1 lib/mongo_mapper/extensions/integer.rb
mongo_mapper-0.11.1 lib/mongo_mapper/extensions/integer.rb
mongo_mapper-0.11.0 lib/mongo_mapper/extensions/integer.rb
mongo_mapper-0.10.1 lib/mongo_mapper/extensions/integer.rb
mongo_mapper-0.10.0 lib/mongo_mapper/extensions/integer.rb
mongo_mapper-0.9.2 lib/mongo_mapper/extensions/integer.rb
jonbell-mongo_mapper-0.8.6 lib/mongo_mapper/extensions/integer.rb
mongo_mapper-0.9.1 lib/mongo_mapper/extensions/integer.rb
mongo_mapper-0.9.0 lib/mongo_mapper/extensions/integer.rb
ign-mongo_mapper-0.8.6.2 lib/mongo_mapper/extensions/integer.rb
ign-mongo_mapper-0.8.6.1 lib/mongo_mapper/extensions/integer.rb
ssherman-mongo_mapper-0.8.6 lib/mongo_mapper/extensions/integer.rb
mongo_mapper-0.8.6 lib/mongo_mapper/extensions/integer.rb
mongo_mapper-0.8.5 lib/mongo_mapper/extensions/integer.rb
honkster-mongo_mapper-0.8.4 lib/mongo_mapper/extensions/integer.rb
mongo_mapper-0.8.4 lib/mongo_mapper/extensions/integer.rb
mongo_mapper-unstable-2010.08.19 lib/mongo_mapper/extensions/integer.rb