Method: Mongoid::Fields::ClassMethods#extract_id_field

Defined in:
lib/mongoid/fields.rb

#extract_id_field(attributes) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Extracts the id field from the specified attributes hash based on aliases defined in this class.

Parameters:

  • attributes (Hash)

    The attributes to inspect.

Returns:

  • (Object)

    The id value.



83
84
85
86
87
88
89
90
# File 'lib/mongoid/fields.rb', line 83

def extract_id_field(attributes)
  id_fields.each do |k|
    if v = attributes[k]
      return v
    end
  end
  nil
end