lib/bson/encodable.rb
def encode_binary_data_with_placeholder(encoded = ''.force_encoding(BINARY))
      pos = encoded.bytesize
      encoded << PLACEHOLDER
      yield(encoded)
      encoded.set_int32(pos, encoded.bytesize - pos - 5)
      encoded
    end
# Encodes binary data with a generic placeholder value to be written later
# once all bytes have been written.
#
# @example Encode the BSON with placeholder bytes.
#   string.encode_binary_data_with_placeholder(encoded) do |encoded|
#     each do |field, value|
#       value.to_bson(encoded)
#     end
#   end
#
# @param [ String ] encoded The string to encode.
#
# @return [ String ] The encoded string.
#
# @since 2.0.0
Encodes binary data with a generic placeholder value to be written later
once all bytes have been written.
Encodes binary data with a generic placeholder value to be written later once all bytes have been written .
def encode_binary_data_with_placeholder(encoded = ''.force_encoding(BINARY))
      pos = encoded.bytesize
      encoded << PLACEHOLDER
      yield(encoded)
      encoded.set_int32(pos, encoded.bytesize - pos - 5)
      encoded
    end
def encode_binary_data_with_placeholder ( encoded = '' . force_encoding ( BINARY ) ) pos = encoded . bytesize encoded << PLACEHOLDER yield ( encoded ) encoded . set_int32 ( pos , encoded . bytesize - pos - 5 ) encoded end
Encodes binary data with a generic placeholder value to be written later
once all bytes have been written.
Encodes binary data with a generic placeholder value to be written later once all bytes have been written .
The encoded string.
The encoded string .
 String 
encoded
force_encoding
encoded The string to encode.
encoded The string to encode .
example
Encode the BSON with placeholder bytes. string.encode_binary_data_with_placeholder(encoded) do |encoded| each do |field, value| value.to_bson(encoded) end end
Encode the BSON with placeholder bytes . string . encode_binary_data_with_placeholder ( encoded ) do |encoded| each do |field value| value . to_bson ( encoded ) end end
since
None