Skip to content

Commit

Permalink
Remove String#mongoid_id? and Symbol#mongoid_id?
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyshields committed Sep 2, 2023
1 parent 30f46d4 commit c7d63d6
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 82 deletions.
10 changes: 0 additions & 10 deletions lib/mongoid/extensions/string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ 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.
def mongoid_id?
self =~ /\A(|_)id\z/
end

# Is the string a number? The literals "NaN", "Infinity", and "-Infinity"
# are counted as numbers.
#
Expand Down
10 changes: 0 additions & 10 deletions lib/mongoid/extensions/symbol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ 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.
def mongoid_id?
to_s.mongoid_id?
end

module ClassMethods

# Turn the object from the ruby type we deal with to a Mongo friendly
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 c7d63d6

Please sign in to comment.