Module: BSON::Object

Defined in:
lib/bson/object.rb

Overview

Injects behaviour for all Ruby objects.

Since:

  • 2.2.4

Instance Method Summary collapse

Instance Method Details

#to_bson_key(encoded = ''.force_encoding(BINARY)) ⇒ Object

Objects that don’t override this method will raise an error when trying to use them as keys in a BSON document. This is only overridden in String and Symbol.

Examples:

Convert the object to a BSON key.

object.to_bson_key

Raises:

  • Always raises an exception.

See Also:

Since:

  • 2.2.4



34
35
36
# File 'lib/bson/object.rb', line 34

def to_bson_key(encoded = ''.force_encoding(BINARY))
  raise InvalidKey.new(self)
end