Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Spree::Address#empty? #1680

Merged
merged 2 commits into from
Jan 16, 2017

Conversation

jhawthorn
Copy link
Contributor

Empty is a confusing method to have on an object because it affects the behaviour of blank? and present?

> Spree::Address.new.present?
false

We should remove empty to avoid this confusion

It's currently defined as

def empty?
  attributes.except('id', 'created_at', 'updated_at', 'country_id').all? { |_, v| v.nil? }
end

Which is basically the same as new_record? && country_id.nil?

This fixes #416

Previously this would return Address#empty?, but an Address should
always be considered present.
@jhawthorn jhawthorn force-pushed the deprecate_address_empty branch from f33b59c to 2638d1b Compare January 11, 2017 00:23
Copy link
Contributor

@cbrunsdon cbrunsdon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good by me, thanks.

@jhawthorn jhawthorn merged commit 8ae8ec4 into solidusio:master Jan 16, 2017
@jhawthorn jhawthorn deleted the deprecate_address_empty branch January 16, 2017 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove Address#empty?
2 participants