Sha256: dc756e988f5328abd4b8ebbe8f628de2f4d5b2a4ac683204ff838d761e084539

Contents?: true

Size: 1.13 KB

Versions: 122

Compression:

Stored size: 1.13 KB

Contents

include Java
module BSON
  class BSON_JAVA

    # TODO: Pool or cache instances of RubyBSONEncoder so that
    # we don't create a new one on each call to #serialize.
    def self.serialize(obj, check_keys=false, move_id=false, max_bson_size=BSON::DEFAULT_MAX_BSON_SIZE)
      raise InvalidDocument, "BSON_JAVA.serialize takes a Hash" unless obj.is_a?(Hash)
      enc = Java::OrgJbson::RubyBSONEncoder.new(JRuby.runtime, check_keys, move_id, max_bson_size)
      ByteBuffer.new(enc.encode(obj))
    end

    def self.deserialize(buf)
      dec = Java::OrgJbson::RubyBSONDecoder.new
      callback = Java::OrgJbson::RubyBSONCallback.new(JRuby.runtime)
      dec.decode(buf.to_s.to_java_bytes, callback)
      callback.get
    end

    def self.max_bson_size
      warn "BSON::BSON_CODER.max_bson_size is deprecated and will be removed in v2.0."
      Java::OrgJbson::RubyBSONEncoder.max_bson_size(self)
    end

    def self.update_max_bson_size(connection)
      warn "BSON::BSON_CODER.update_max_bson_size is deprecated and now a no-op. It will be removed in v2.0."
      Java::OrgJbson::RubyBSONEncoder.update_max_bson_size(self, connection)
    end
  end
end

Version data entries

122 entries across 76 versions & 3 rubygems

Version Path
classiccms-0.5.14 vendor/bundle/gems/bson-1.6.2/lib/bson/bson_java.rb
classiccms-0.5.14 vendor/bundle/gems/bson-1.6.1/lib/bson/bson_java.rb
classiccms-0.5.13 vendor/bundle/gems/bson-1.6.1/lib/bson/bson_java.rb
classiccms-0.5.13 vendor/bundle/gems/bson-1.6.2/lib/bson/bson_java.rb
classiccms-0.5.12 vendor/bundle/gems/bson-1.6.1/lib/bson/bson_java.rb
classiccms-0.5.12 vendor/bundle/gems/bson-1.6.2/lib/bson/bson_java.rb
classiccms-0.5.11 vendor/bundle/gems/bson-1.6.1/lib/bson/bson_java.rb
classiccms-0.5.11 vendor/bundle/gems/bson-1.6.2/lib/bson/bson_java.rb
bson-1.7.0-java lib/bson/bson_java.rb
bson-1.7.0 lib/bson/bson_java.rb
classiccms-0.5.10 vendor/bundle/gems/bson-1.6.2/lib/bson/bson_java.rb
classiccms-0.5.10 vendor/bundle/gems/bson-1.6.1/lib/bson/bson_java.rb
classiccms-0.5.9 vendor/bundle/gems/bson-1.6.1/lib/bson/bson_java.rb
classiccms-0.5.9 vendor/bundle/gems/bson-1.6.2/lib/bson/bson_java.rb
bson-1.7.0.rc0-java lib/bson/bson_java.rb
bson-1.7.0.rc0 lib/bson/bson_java.rb
classiccms-0.5.8 vendor/bundle/gems/bson-1.6.1/lib/bson/bson_java.rb
classiccms-0.5.8 vendor/bundle/gems/bson-1.6.2/lib/bson/bson_java.rb
classiccms-0.5.7 vendor/bundle/gems/bson-1.6.1/lib/bson/bson_java.rb
classiccms-0.5.7 vendor/bundle/gems/bson-1.6.2/lib/bson/bson_java.rb