Skip to content

Commit

Permalink
deprecate, don't remove
Browse files Browse the repository at this point in the history
  • Loading branch information
jamis committed Nov 7, 2023
1 parent a4dde91 commit 6d7d7d2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/mongoid/extensions/hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,31 @@ def _mongoid_unsatisfiable_criteria?
# @deprecated
alias :blank_criteria? :_mongoid_unsatisfiable_criteria?

# Deletes an id value from the hash.
#
# @example Delete an id value.
# {}.delete_id
#
# @return [ Object ] The deleted value, or nil.
# @deprecated
def delete_id
delete("_id") || delete(:_id) || delete("id") || delete(:id)
end
Mongoid.deprecate(self, :delete_id)

# Get the id attribute from this hash, whether it's prefixed with an
# underscore or is a symbol.
#
# @example Extract the id.
# { :_id => 1 }.extract_id
#
# @return [ Object ] The value of the id.
# @deprecated
def extract_id
self["_id"] || self[:_id] || self["id"] || self[:id]
end
Mongoid.deprecate(self, :extract_id)

# Turn the object from the ruby type we deal with to a Mongo friendly
# type.
#
Expand Down

0 comments on commit 6d7d7d2

Please sign in to comment.