Method: Mongoid::Extensions::Hash#extract_id

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

#extract_idObject

Deprecated.

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.



70
71
72
# File 'lib/mongoid/extensions/hash.rb', line 70

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