Method: Mongoid::Extensions::Hash::CriteriaHelpers#extract_id

Defined in:
lib/mongoid/extensions/hash/criteria_helpers.rb

#extract_idObject

Get the id attribute from this hash, whether it’s prefixed with an underscore or is a symbol.

Examples:

Extract the id.

{ :_id => 1 }.extract_id

Returns:

  • (Object)

    The value of the id.

Since:

  • 2.3.2



41
42
43
# File 'lib/mongoid/extensions/hash/criteria_helpers.rb', line 41

def extract_id
  self["id"] || self["_id"] || self[:id] || self[:_id]
end