Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/bson/string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ def to_bson_cstring(encoded = ''.force_encoding(BINARY))
def to_bson_object_id
ObjectId.repair(self)
end

# A shortcut to BSON::ObjectId.from_string('048fec556265664f5b110000')
# @example Convert the string to an object id.
# '048fec556265664f5b110000'.to_object_id
def to_object_id
BSON::ObjectId.from_string(self)
end

# Convert the string to a UTF-8 string then force to binary. This is so
# we get errors for strings that are not UTF-8 encoded.
Expand Down