Method: Mongo::ObjectID#initialize

Defined in:
lib/mongo/types/objectid.rb

#initialize(data = nil) ⇒ ObjectID

Create a new object id. If no parameter is given, an id corresponding to the ObjectID BSON data type will be created. This is a 12-byte value consisting of a 4-byte timestamp, a 3-byte machine id, a 2-byte process id, and a 3-byte counter.

Parameters:

  • data (Array) (defaults to: nil)

    should be an array of bytes. If you want to generate a standard MongoDB object id, leave this argument blank.



37
38
39
# File 'lib/mongo/types/objectid.rb', line 37

def initialize(data=nil)
  @data = data || generate
end