Module: BSON::NilClass

Defined in:
lib/bson/nil_class.rb

Overview

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

See Also:

Since:

  • 2.0.0

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

BSON_TYPE =

A nil is type 0x0A in the BSON spec.

Since:

  • 2.0.0

10.chr.force_encoding(BINARY).freeze

Instance Method Summary collapse

Instance Method Details

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

Get the nil as encoded BSON.

Examples:

Get the nil as encoded BSON.

nil.to_bson

Returns:

  • (String)

    An empty string.

See Also:

Since:

  • 2.0.0



40
41
42
# File 'lib/bson/nil_class.rb', line 40

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