def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?)
      position = buffer.length
      buffer.put_int32(0)
      buffer.put_string(javascript)
      scope.to_bson(buffer)
      buffer.replace_int32(position, buffer.length - position)
    end
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?)
      position = buffer.length
      buffer.put_int32(0)
      buffer.put_string(javascript)
      scope.to_bson(buffer)
      buffer.replace_int32(position, buffer.length - position)
    end
Instantiate the new code with scope.

 @example Instantiate the code with scope.
   BSON::CodeWithScope.new("this.value = name", name: "sid")

 @param [ String ] javascript The javascript code.
 @param [ Hash ] scope The variable scope.

 @since 2.0.0
 Encode the javascript code with scope.

 @example Encode the code with scope.
   code_with_scope.to_bson

 @return [ BSON::ByteBuffer ] The buffer with the encoded object.

 @see http://bsonspec.org/#/specification

 @since 2.0.0