class BSON::Symbol::Raw
def ==(other)
-
(true, false)
- If the objects are equal.
Parameters:
-
other
(Object
) -- The object to check against.
def ==(other) return false unless other.is_a?(Raw) to_sym == other.to_sym end
def as_extended_json(**_options)
-
(Hash)
- The extended json representation.
def as_extended_json(**_options) { '$symbol' => to_s } end
def as_json(*args)
-
(String)
- The raw symbol as a String.
Other tags:
- Example: Get the raw symbol as a JSON-serializable object. -
def as_json(*args) to_s end
def bson_type
def bson_type Symbol::BSON_TYPE end
def initialize(str_or_sym)
- See: http://bsonspec.org/#/specification -
Parameters:
-
str_or_sym
(String | Symbol
) -- The symbol represented by this
def initialize(str_or_sym) unless str_or_sym.is_a?(String) || str_or_sym.is_a?(Symbol) raise ArgumentError, "BSON::Symbol::Raw must be given a symbol or a string, not #{str_or_sym}" end @symbol = str_or_sym.to_sym end
def to_bson(buffer = ByteBuffer.new)
- See: http://bsonspec.org/#/specification -
Returns:
-
(BSON::ByteBuffer)
- The buffer with the encoded object.
Raises:
-
(EncodingError)
- If the symbol is not UTF-8.
def to_bson(buffer = ByteBuffer.new) buffer.put_string(to_s) end
def to_s
-
(String)
- The symbol as a string.
def to_s @symbol.to_s end
def to_sym
-
(Symbol)
- The symbol represented by this BSON object.
def to_sym @symbol end