Skip to content

Commit fc98ff0

Browse files
johnnyshieldsjamis
andauthored
MONGOID-5668 [Monkey Patch Removal] Remove String/Symbol#mongoid_id? (#5703)
* Remove String#mongoid_id? and Symbol#mongoid_id? * deprecate instead of remove --------- Co-authored-by: Jamis Buck <[email protected]>
1 parent c304589 commit fc98ff0

File tree

4 files changed

+4
-62
lines changed

4 files changed

+4
-62
lines changed

lib/mongoid/extensions/string.rb

+2
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ def collectionize
7171
# "_id".mongoid_id?
7272
#
7373
# @return [ true | false ] If the string is id or _id.
74+
# @deprecated
7475
def mongoid_id?
7576
self =~ /\A(|_)id\z/
7677
end
78+
Mongoid.deprecate(self, :mongoid_id?)
7779

7880
# Is the string a number? The literals "NaN", "Infinity", and "-Infinity"
7981
# are counted as numbers.

lib/mongoid/extensions/symbol.rb

+2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ module Symbol
1313
# :_id.mongoid_id?
1414
#
1515
# @return [ true | false ] If the symbol is :id or :_id.
16+
# @deprecated
1617
def mongoid_id?
1718
to_s.mongoid_id?
1819
end
20+
Mongoid.deprecate(self, :mongoid_id?)
1921

2022
module ClassMethods
2123

spec/mongoid/extensions/string_spec.rb

-31
Original file line numberDiff line numberDiff line change
@@ -172,37 +172,6 @@ class Patient
172172
end
173173
end
174174

175-
describe "#mongoid_id?" do
176-
177-
context "when the string is id" do
178-
179-
it "returns true" do
180-
expect("id").to be_mongoid_id
181-
end
182-
end
183-
184-
context "when the string is _id" do
185-
186-
it "returns true" do
187-
expect("_id").to be_mongoid_id
188-
end
189-
end
190-
191-
context "when the string contains id" do
192-
193-
it "returns false" do
194-
expect("identity").to_not be_mongoid_id
195-
end
196-
end
197-
198-
context "when the string contains _id" do
199-
200-
it "returns false" do
201-
expect("something_id").to_not be_mongoid_id
202-
end
203-
end
204-
end
205-
206175
[ :mongoize, :demongoize ].each do |method|
207176

208177
describe ".#{method}" do

spec/mongoid/extensions/symbol_spec.rb

-31
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,6 @@
55

66
describe Mongoid::Extensions::Symbol do
77

8-
describe "#mongoid_id?" do
9-
10-
context "when the string is id" do
11-
12-
it "returns true" do
13-
expect(:id).to be_mongoid_id
14-
end
15-
end
16-
17-
context "when the string is _id" do
18-
19-
it "returns true" do
20-
expect(:_id).to be_mongoid_id
21-
end
22-
end
23-
24-
context "when the string contains id" do
25-
26-
it "returns false" do
27-
expect(:identity).to_not be_mongoid_id
28-
end
29-
end
30-
31-
context "when the string contains _id" do
32-
33-
it "returns false" do
34-
expect(:something_id).to_not be_mongoid_id
35-
end
36-
end
37-
end
38-
398
[ :mongoize, :demongoize ].each do |method|
409

4110
describe ".mongoize" do

0 commit comments

Comments
 (0)