From 2af96c87963301da6006e6c926618a2091617fcb Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Mon, 4 Sep 2023 02:34:13 +0900 Subject: [PATCH 1/2] Define #resizable instance and class methods for Set --- lib/mongoid/extensions/set.rb | 20 ++++++++++++++++++++ spec/mongoid/extensions/array_spec.rb | 2 +- spec/mongoid/extensions/set_spec.rb | 14 ++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/lib/mongoid/extensions/set.rb b/lib/mongoid/extensions/set.rb index 21a887a5f6..a607288d90 100644 --- a/lib/mongoid/extensions/set.rb +++ b/lib/mongoid/extensions/set.rb @@ -18,6 +18,16 @@ def mongoize ::Set.mongoize(self) end + # Returns whether the object's size can be changed. + # + # @example Is the object resizable? + # object.resizable? + # + # @return [ true ] true. + def resizable? + true + end + module ClassMethods # Convert the object from its mongo friendly ruby type to this type. @@ -51,6 +61,16 @@ def mongoize(object) when ::Array then ::Array.mongoize(object).uniq end end + + # Returns whether the object's size can be changed. + # + # @example Is the object resizable? + # et.resizable? + # + # @return [ true ] true. + def resizable? + true + end end end end diff --git a/spec/mongoid/extensions/array_spec.rb b/spec/mongoid/extensions/array_spec.rb index 18ab1ee2f2..787e3feec9 100644 --- a/spec/mongoid/extensions/array_spec.rb +++ b/spec/mongoid/extensions/array_spec.rb @@ -612,7 +612,7 @@ end end - describe "#resiable?" do + describe "#resizable?" do it "returns true" do expect([]).to be_resizable diff --git a/spec/mongoid/extensions/set_spec.rb b/spec/mongoid/extensions/set_spec.rb index cde2d7da01..788c743c23 100644 --- a/spec/mongoid/extensions/set_spec.rb +++ b/spec/mongoid/extensions/set_spec.rb @@ -139,4 +139,18 @@ end end end + + describe ".resizable?" do + + it "returns true" do + expect(Set).to be_resizable + end + end + + describe "#resizable?" do + + it "returns true" do + expect(Set.new).to be_resizable + end + end end From 25930d06480217bd0b0396c076c79aaa7c3ba1fe Mon Sep 17 00:00:00 2001 From: Johnny Shields <27655+johnnyshields@users.noreply.github.com> Date: Mon, 4 Sep 2023 02:38:25 +0900 Subject: [PATCH 2/2] Update set.rb --- lib/mongoid/extensions/set.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mongoid/extensions/set.rb b/lib/mongoid/extensions/set.rb index a607288d90..8fcf12aaa1 100644 --- a/lib/mongoid/extensions/set.rb +++ b/lib/mongoid/extensions/set.rb @@ -65,7 +65,7 @@ def mongoize(object) # Returns whether the object's size can be changed. # # @example Is the object resizable? - # et.resizable? + # Set.resizable? # # @return [ true ] true. def resizable?