Namespace

BSON::Symbol

Injects behaviour for encoding and decoding symbol values to and from raw bytes as specified by the BSON spec.

@note Symbols are deprecated in the BSON spec, but they are still

currently supported here for backwards compatibility.

@see bsonspec.org/#/specification

@since 2.0.0

Constants

BSON_TYPE

A symbol is type 0x0E in the BSON spec.

@since 2.0.0

Public Instance Methods

to_bson(encoded = ''.force_encoding(BINARY)) click to toggle source

Get the symbol as encoded BSON.

@example Get the symbol as encoded BSON.

:test.to_bson

@return [ Symbol ] The encoded symbol.

@see bsonspec.org/#/specification

@since 2.0.0

# File lib/bson/symbol.rb, line 43
def to_bson(encoded = ''.force_encoding(BINARY))
  to_s.to_bson(encoded)
end
to_bson_key(encoded = ''.force_encoding(BINARY)) click to toggle source

Get the symbol as a BSON key name encoded C symbol.

@example Get the symbol as a key name.

:test.to_bson_key

@return [ String ] The encoded symbol as a BSON key.

@see bsonspec.org/#/specification

@since 2.0.0

# File lib/bson/symbol.rb, line 57
def to_bson_key(encoded = ''.force_encoding(BINARY))
  to_s.to_bson_key(encoded)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.