Module: Mongoid::Keys

Extended by:
ActiveSupport::Concern
Included in:
Components
Defined in:
lib/mongoid/keys.rb

Overview

This module defines the behaviour for overriding the default ids on documents.

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



9
10
11
# File 'lib/mongoid/keys.rb', line 9

def identifier
  @identifier
end

Instance Method Details

#primary_keyArray

Note:

Refactored from using delegate for class load performance.

Get the document’s primary key.

Examples:

Get the primary key.

model.primary_key

Returns:

  • (Array)

    The primary key



24
25
26
# File 'lib/mongoid/keys.rb', line 24

def primary_key
  self.class.primary_key
end

#using_object_ids?true, false

Note:

Refactored from using delegate for class load performance.

Is the document using object ids?

Examples:

Is the document using object ids?

model.using_object_ids?

Returns:

  • (true, false)

    Using object ids.



36
37
38
# File 'lib/mongoid/keys.rb', line 36

def using_object_ids?
  self.class.using_object_ids?
end