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

remove redundant delegation from product model #2427

Merged
merged 1 commit into from
Dec 20, 2017

Conversation

brchristian
Copy link
Contributor

It appears that since b6cd1ad we have declared delegate twice for the :display_amount and :display_price attributes in the product model -- once in the MASTER_ATTRIBUTES line and once explicitly below.

This PR removes the redundant second declaration.

@kennyadsl
Copy link
Member

I'm not sure all attributes inside the MASTER_ATTRIBUTES array should have a setter. For example the 2 duplicated attributes do not seem to have setters method. Maybe it's better to remove stuff from the MASTER_ATTRIBUTES array if not needed.

@brchristian
Copy link
Contributor Author

Hi @kennyadsl thanks for taking a look. To clarify, you would like me to leave :display_amount and :display_price in the getter method line below, but remove them from the MASTER_ATTRIBUTES getter+setter block above?

@kennyadsl
Copy link
Member

Yes, I think it's better at a first look, even if I honestly didn't investigate deeply.

I think we don't have display_amount= and display_price= on Spree::Variant (or somewhere else) so it's probably better to do not delegate them, you can test this by trying to assign for example a display_price to a variant:

# rails console
> Spree::Product.first.display_price = 12
NoMethodError: undefined method `display_price=' for #<Spree::Variant:0x007fa80910e498>

They are not technically attributes, so I think it's better to have them in the delegate below, which just delegate the method without the method_name= part.

Along with those two methods, I think we can remove other elements from that list, but maybe we can do that in another PR?

Sorry for not being clear on my first comment and thanks for your contribution.

@brchristian
Copy link
Contributor Author

Your earlier comment was quite clear, I just wanted to double check before I did anything!

That all makes total sense to me and I’ve made the changes and pushed the latest version to this branch just now.

Copy link
Contributor

@jhawthorn jhawthorn left a comment

Choose a reason for hiding this comment

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

Thank you

@jhawthorn jhawthorn merged commit ce908da into solidusio:master Dec 20, 2017
@brchristian brchristian deleted the product_delegate branch December 21, 2017 00:04
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.

3 participants