Sha256: 8b9c07fda7eb1177795a63fb07182042e17a8edef4c3a38b04068809cfa6afa9
Contents?: true
Size: 752 Bytes
Versions: 3
Compression:
Stored size: 752 Bytes
Contents
module Moped module BSON # @private module Extensions module String module ClassMethods def __bson_load__(io) io.read(*io.read(4).unpack(INT32_PACK)).chop!.force_encoding('utf-8') end end def __bson_dump__(io, key) io << Types::STRING io << key io << NULL_BYTE begin data = encode('utf-8') rescue EncodingError data = dup data.force_encoding('utf-8') raise unless data.valid_encoding? end data.force_encoding('binary') io << [data.bytesize+1].pack(INT32_PACK) io << data io << NULL_BYTE end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
moped-1.0.0.rc | lib/moped/bson/extensions/string.rb |
moped-1.0.0.beta | lib/moped/bson/extensions/string.rb |
moped-1.0.0.alpha | lib/moped/bson/extensions/string.rb |