Skip to content

Commit

Permalink
deprecate instead of remove
Browse files Browse the repository at this point in the history
  • Loading branch information
jamis committed Nov 7, 2023
1 parent c7d63d6 commit 6b1d221
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/mongoid/extensions/string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ def collectionize
tableize.gsub("/", "_")
end

# Is the string a valid value for a Mongoid id?
#
# @example Is the string an id value?
# "_id".mongoid_id?
#
# @return [ true | false ] If the string is id or _id.
# @deprecated
def mongoid_id?
self =~ /\A(|_)id\z/
end
Mongoid.deprecate(self, :mongoid_id?)

# Is the string a number? The literals "NaN", "Infinity", and "-Infinity"
# are counted as numbers.
#
Expand Down
12 changes: 12 additions & 0 deletions lib/mongoid/extensions/symbol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ module Extensions
# Adds type-casting behavior to Symbol class.
module Symbol

# Is the symbol a valid value for a Mongoid id?
#
# @example Is the string an id value?
# :_id.mongoid_id?
#
# @return [ true | false ] If the symbol is :id or :_id.
# @deprecated
def mongoid_id?
to_s.mongoid_id?
end
Mongoid.deprecate(self, :mongoid_id?)

module ClassMethods

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

0 comments on commit 6b1d221

Please sign in to comment.