Skip to content

Commit

Permalink
MONGOID-5668 [Monkey Patch Removal] Remove String/Symbol#mongoid_id? (#…
Browse files Browse the repository at this point in the history
…5703)

* Remove String#mongoid_id? and Symbol#mongoid_id?

* deprecate instead of remove

---------

Co-authored-by: Jamis Buck <[email protected]>
  • Loading branch information
johnnyshields and jamis authored Nov 7, 2023
1 parent c304589 commit fc98ff0
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 62 deletions.
2 changes: 2 additions & 0 deletions lib/mongoid/extensions/string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ def collectionize
# "_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
2 changes: 2 additions & 0 deletions lib/mongoid/extensions/symbol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ module Symbol
# :_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

Expand Down
31 changes: 0 additions & 31 deletions spec/mongoid/extensions/string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,37 +172,6 @@ class Patient
end
end

describe "#mongoid_id?" do

context "when the string is id" do

it "returns true" do
expect("id").to be_mongoid_id
end
end

context "when the string is _id" do

it "returns true" do
expect("_id").to be_mongoid_id
end
end

context "when the string contains id" do

it "returns false" do
expect("identity").to_not be_mongoid_id
end
end

context "when the string contains _id" do

it "returns false" do
expect("something_id").to_not be_mongoid_id
end
end
end

[ :mongoize, :demongoize ].each do |method|

describe ".#{method}" do
Expand Down
31 changes: 0 additions & 31 deletions spec/mongoid/extensions/symbol_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,6 @@

describe Mongoid::Extensions::Symbol do

describe "#mongoid_id?" do

context "when the string is id" do

it "returns true" do
expect(:id).to be_mongoid_id
end
end

context "when the string is _id" do

it "returns true" do
expect(:_id).to be_mongoid_id
end
end

context "when the string contains id" do

it "returns false" do
expect(:identity).to_not be_mongoid_id
end
end

context "when the string contains _id" do

it "returns false" do
expect(:something_id).to_not be_mongoid_id
end
end
end

[ :mongoize, :demongoize ].each do |method|

describe ".mongoize" do
Expand Down

0 comments on commit fc98ff0

Please sign in to comment.