From cf92988f0f27c4b9ab7d18a4e52d76e890429918 Mon Sep 17 00:00:00 2001 From: Trey Pendragon Date: Fri, 15 Oct 2021 17:12:38 -0700 Subject: [PATCH] Remove deprecated string equality functionality. Prep for 3.0 --- lib/valkyrie.rb | 13 ------------- lib/valkyrie/id.rb | 17 +---------------- spec/valkyrie/types_spec.rb | 30 ++++-------------------------- 3 files changed, 5 insertions(+), 55 deletions(-) diff --git a/lib/valkyrie.rb b/lib/valkyrie.rb index 69e1e68c6..13de7d6f7 100644 --- a/lib/valkyrie.rb +++ b/lib/valkyrie.rb @@ -87,19 +87,6 @@ def storage_adapter Valkyrie::StorageAdapter.find(super.to_sym) end - # @api public - # Configure id_string_equality to be true in order to make Valkyrie::ID - # equal to the string value they contain. This will be the default behavior - # in v3.0.0. - # - # @return [Boolean] Whether `Valkyrie::ID` should be equal to their string counterpart. - def id_string_equality - super - end - - # @!attribute [w] id_string_equality= - # The setter for #id_string_equality; see it's implementation - # @api public # # The returned anonymous method (e.g. responds to #call) has a signature of diff --git a/lib/valkyrie/id.rb b/lib/valkyrie/id.rb index d1df4bcb6..26cead625 100644 --- a/lib/valkyrie/id.rb +++ b/lib/valkyrie/id.rb @@ -25,27 +25,12 @@ def to_str delegate :hash, to: :state def eql?(other) - return string_equality(other) if Valkyrie.config.id_string_equality == true - default_equality(other) + other == to_str end alias == eql? protected - def default_equality(other) - output = (other.class == self.class && other.state == state) - return output if output == true - if output == false && string_equality(other) && Valkyrie.config.id_string_equality.nil? - warn "[DEPRECATION] Valkyrie::IDs will always be equal to their string counterparts in 3.0.0. " \ - "To silence this message, please either compare IDs or set Valkyrie.config.id_string_equality = true." - end - false - end - - def string_equality(other) - other == to_str - end - def state [@id] end diff --git a/spec/valkyrie/types_spec.rb b/spec/valkyrie/types_spec.rb index 079137f54..6ee5ebe09 100755 --- a/spec/valkyrie/types_spec.rb +++ b/spec/valkyrie/types_spec.rb @@ -35,40 +35,18 @@ class Resource < Valkyrie::Resource end context 'when a string is passed in' do - let(:message) do - /\[DEPRECATION\] Valkyrie::IDs will always be equal to their string counterparts in 3.0.0. To silence this message, please either compare IDs or set Valkyrie.config.id_string_equality = true./ - end let(:thumbnail_id) { '123' } it 'casts to a string' do expect(resource.thumbnail_id).to eq Valkyrie::ID.new('123') end - it "echos a deprecated message if not configured" do - allow(Valkyrie.config).to receive(:id_string_equality).and_return(nil) - - expect do - expect(resource.thumbnail_id).not_to eq '123' - end.to output(message).to_stderr - end - - it "doesn't echo a deprecated message if configured" do - allow(Valkyrie.config).to receive(:id_string_equality).and_return(false) - expect do - expect(resource.thumbnail_id).not_to eq '123' - end.not_to output(message).to_stderr + it 'equals the equivalent string' do + expect(resource.thumbnail_id).to eq '123' end - context 'when String equality is configured' do - before { allow(Valkyrie.config).to receive(:id_string_equality).and_return(true) } - - it 'equals the equivalent string' do - expect(resource.thumbnail_id).to eq '123' - end - - it 'is equal to the equivalent string' do - expect('123' == resource.thumbnail_id).to be true - end + it 'is equal to the equivalent string' do + expect('123' == resource.thumbnail_id).to be true end end