Method: BSON::ObjectId.repair

Defined in:
lib/bson/object_id.rb

.repair(object) ⇒ String

Executes the provided block only if the size of the provided object is

  1. Used in legacy id repairs.

Examples:

Execute in a repairing block.

BSON::ObjectId.repair("test") { obj }

Parameters:

Returns:

  • (String)

    The result of the block.

Raises:

Since:

  • 2.0.0



353
354
355
356
357
# File 'lib/bson/object_id.rb', line 353

def repair(object)
  raise Error::InvalidObjectId, "#{object.inspect} is not a valid object id." if object.size != 12

  block_given? ? yield(object) : object
end