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

Refactor Product#available? to match docs #3733

Merged
merged 1 commit into from
Aug 19, 2020

Conversation

brchristian
Copy link
Contributor

Description

This is a very small quality-of-life type improvement, but I noticed that the safe navigation operator can be used to simplify the logic of the Product#available? method.

Rephrasing the logic this way we:

  • Have two(ish) conditions instead of three
  • Avoid the semantic confusion of "not nil or future"
  • Flip the deleted and available_on conditions, to better match the docs, which say,
    A product is available if it has not been deleted and the available_on date is in the past.

It’s not earth shattering by any means, but it makes the code that much more readable IMO, especially for folks new to Solidus.

Copy link
Member

@spaghetticode spaghetticode left a comment

Choose a reason for hiding this comment

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

@brchristian thanks! 👍

@spaghetticode spaghetticode merged commit b0c1e7a into solidusio:master Aug 19, 2020
@brchristian brchristian deleted the patch-4 branch August 19, 2020 15:39
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