From 5fb3f4be989e2293b5aa3f4fed104c43551c9260 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 10 Jan 2017 14:27:00 -0800 Subject: [PATCH 1/2] Deprecate Spree::Address#empty? --- core/app/models/spree/address.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/app/models/spree/address.rb b/core/app/models/spree/address.rb index e7f990023b6..65e7ff26b05 100644 --- a/core/app/models/spree/address.rb +++ b/core/app/models/spree/address.rb @@ -106,16 +106,17 @@ def ==(other_address) end def same_as?(other_address) - Spree::Deprecation.warn("Address.same_as? is deprecated. It's equivalent to Address.==", caller) + Spree::Deprecation.warn("Address#same_as? is deprecated. It's equivalent to Address.==", caller) self == other_address end def same_as(other_address) - Spree::Deprecation.warn("Address.same_as is deprecated. It's equivalent to Address.==", caller) + Spree::Deprecation.warn("Address#same_as is deprecated. It's equivalent to Address.==", caller) self == other_address end def empty? + Spree::Deprecation.warn("Address#empty? is deprecated.", caller) attributes.except('id', 'created_at', 'updated_at', 'country_id').all? { |_, v| v.nil? } end From 2638d1b49c63fc67bfaa48acf95826b83e1c7603 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 10 Jan 2017 14:44:59 -0800 Subject: [PATCH 2/2] Fix Address#blank? Previously this would return Address#empty?, but an Address should always be considered present. --- core/app/models/spree/address.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/app/models/spree/address.rb b/core/app/models/spree/address.rb index 65e7ff26b05..6e4890039a6 100644 --- a/core/app/models/spree/address.rb +++ b/core/app/models/spree/address.rb @@ -115,11 +115,19 @@ def same_as(other_address) self == other_address end + # @deprecated Do not use this def empty? Spree::Deprecation.warn("Address#empty? is deprecated.", caller) attributes.except('id', 'created_at', 'updated_at', 'country_id').all? { |_, v| v.nil? } end + # This exists because the default Object#blank?, checks empty? if it is + # defined, and we have defined empty. + # This should be removed once empty? is removed + def blank? + false + end + # @return [Hash] an ActiveMerchant compatible address hash def active_merchant_hash {