Class: BSON::Undefined

Inherits:
Object
  • Object
show all
Defined in:
lib/bson/undefined.rb

Overview

Represents the Undefined BSON type

See Also:

Since:

  • 2.0.0

Constant Summary collapse

BSON_TYPE =

Undefined is type 0x06 in the BSON spec.

Since:

  • 2.0.0

6.chr.force_encoding(BINARY).freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_bson(bson) ⇒ Undefined

Deserialize undefined BSON type from BSON.

Parameters:

  • bson (BSON)

    The encoded undefined value.

Returns:

  • (Undefined)

    The decoded undefined value.

See Also:

Since:

  • 2.0.0



65
66
67
# File 'lib/bson/undefined.rb', line 65

def self.from_bson(bson)
  new
end

Instance Method Details

#==(other) ⇒ true, false

Determine if undefined is equal to another object.

Examples:

Check undefined equality.

BSON::Undefined.new == object

Parameters:

  • other (Object)

    The object to check against.

Returns:

  • (true, false)

    If the objects are equal.

Since:

  • 2.0.0



39
40
41
# File 'lib/bson/undefined.rb', line 39

def ==(other)
  self.class == other.class
end

#to_bson(encoded = ''.force_encoding(BINARY)) ⇒ String

Encode the Undefined field - has no value since it only needs the type and field name when being encoded.

Examples:

Encode the undefined value.

Undefined.to_bson

Returns:

  • (String)

    An empty string.

Since:

  • 2.0.0



52
53
54
# File 'lib/bson/undefined.rb', line 52

def to_bson(encoded = ''.force_encoding(BINARY))
  encoded
end