Module: Moped::BSON::Extensions::Integer
- Included in:
- Integer
- Defined in:
- lib/moped/bson/extensions/integer.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- INT32_MIN =
(-(1 << 31)+1)
- INT32_MAX =
((1<<31)-1)
- INT64_MIN =
(-2**64 / 2)
- INT64_MAX =
(2**64 / 2 - 1)
Instance Method Summary collapse
Instance Method Details
#__bson_dump__(io, key) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/moped/bson/extensions/integer.rb', line 13 def __bson_dump__(io, key) if self >= INT32_MIN && self <= INT32_MAX io << Types::INT32 io << key.to_bson_cstring io << [self].pack(INT32_PACK) elsif self >= INT64_MIN && self <= INT64_MAX io << Types::INT64 io << key.to_bson_cstring io << [self].pack(INT64_PACK) else raise RangeError.new("MongoDB can only handle 8-byte ints") end end |