Module: Mongo::Operation::Write::Idable

Included in:
Bulk::Insert, Insert
Defined in:
lib/mongo/operation/write/idable.rb

Overview

This module provides functionality to ensure that documents contain an id field. Used by insert operations (Bulk, legacy, write command inserts).

Since:

  • 2.1.0

Constant Summary

ID_GENERATOR =

The option for a custom id generator.

Since:

  • 2.2.0

:id_generator.freeze

Instance Method Summary collapse

Instance Method Details

#id_generatorIdGenerator

Get the id generator.

Examples:

Get the id generator.

idable.id_generator

Returns:

  • (IdGenerator)

    The default or custom id generator.

Since:

  • 2.2.0



38
39
40
# File 'lib/mongo/operation/write/idable.rb', line 38

def id_generator
  @id_generator ||= (spec[ID_GENERATOR] || ObjectIdGenerator.new)
end