class BSON::Undefined

Represents the Undefined BSON type

@see bsonspec.org/#/specification

@since 2.0.0

Constants

BSON_TYPE

Undefined is type 0x06 in the BSON spec.

@since 2.0.0

Public Instance Methods

==(other) click to toggle source

Determine if undefined is equal to another object.

@example Check undefined equality.

BSON::Undefined.new == object

@param [ Object ] other The object to check against.

@return [ true, false ] If the objects are equal.

@since 2.0.0

# File lib/bson/undefined.rb, line 43
def ==(other)
  self.class == other.class
end
as_extended_json(**options) click to toggle source

Converts this object to a representation directly serializable to Extended JSON (github.com/mongodb/specifications/blob/master/source/extended-json.rst).

@option opts [ nil | :relaxed | :legacy ] :mode Serialization mode

(default is canonical extended JSON)

@return [ Hash ] The extended json representation.

# File lib/bson/undefined.rb, line 66
def as_extended_json(**options)
  { "$undefined" => true }
end
as_json(*args) click to toggle source

Return a string representation of the BSON::Undefined for use in application-level JSON serialization. This method is intentionally different from as_extended_json.

@example Get the undefined as a JSON-serializable object.

undefined.as_json

@return [ nil ] The undefined as nil.

# File lib/bson/undefined.rb, line 55
def as_json(*args)
  nil
end