Module: BSON::Specialized

Included in:
MaxKey, MinKey, NilClass, Undefined
Defined in:
lib/bson/specialized.rb

Overview

Provides behaviour to special values that exist in the BSON spec that don't have a native type, like $minKey and $maxKey.

See Also:

Since:

  • 2.0.0

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ true, false

Determine if the min key is equal to another object.

Examples:

Check min key equality.

BSON::MinKey.new == object

Parameters:

  • other (Object)

    The object to check against.

Returns:

  • (true, false)

    If the objects are equal.

Since:

  • 2.0.0



35
36
37
# File 'lib/bson/specialized.rb', line 35

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

#to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) ⇒ BSON::ByteBuffer

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

Examples:

Encode the min key value.

min_key.to_bson

Returns:

  • (BSON::ByteBuffer)

    The buffer with the encoded object.

Since:

  • 2.0.0



48
49
50
# File 'lib/bson/specialized.rb', line 48

def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?)
  buffer
end