Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MONGOID-5668 [Monkey Patch Removal] Remove String/Symbol#mongoid_id? #5703

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
deprecate instead of remove
jamis committed Nov 7, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 6b1d221acf52c3eda253a69e1bec2fdfb7764cd6
12 changes: 12 additions & 0 deletions lib/mongoid/extensions/string.rb
Original file line number Diff line number Diff line change
@@ -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.
#
12 changes: 12 additions & 0 deletions lib/mongoid/extensions/symbol.rb
Original file line number Diff line number Diff line change
@@ -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