Injects behaviour for encoding and decoding hashes to and from raw bytes as specified by the BSON spec.
@see bsonspec.org/#/specification
@since 2.0.0
Get the hash as encoded BSON.
@example Get the hash as encoded BSON.
{ "field" => "value" }.to_bson
@return [ String ] The encoded string.
@see bsonspec.org/#/specification
@since 2.0.0
# File lib/bson/hash.rb, line 41 def to_bson(encoded = ''.force_encoding(BINARY)) encode_with_placeholder_and_null(BSON_ADJUST, encoded) do |encoded| each do |field, value| encoded << value.bson_type field.to_bson_key(encoded) value.to_bson(encoded) end end end
Generated with the Darkfish Rdoc Generator 2.