Method: BSON::ObjectId#to_s

Defined in:
lib/bson/object_id.rb

#to_sString Also known as: to_str

Get the string representation of the object id.

Examples:

Get the object id as a string.

object_id.to_s

Returns:

  • (String)

    The object id as a string.

Since:

  • 2.0.0



191
192
193
# File 'lib/bson/object_id.rb', line 191

def to_s
  generate_data.to_hex_string.force_encoding(UTF8)
end