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 to FriendlyPromotion::FriendlyPromotionAdjuster #76

Merged
merged 5 commits into from
Nov 6, 2023

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Nov 6, 2023

This changes the API of the main class we're working with from SolidusFriendlyPromotions::OrderDiscounter to
SolidusFriendlyPromotions::FriendlyPromotionsAdjuster. This class now simply calls the three other (otherwise somewhat confusingly named) service objects:

  • LoadPromotions
  • DiscountOrder
  • PersistDiscountedOrder

This makes the code easier to read in my opinion, and simplifies the API for promotion handlers significantly.

@mamhoff mamhoff force-pushed the refactor-discounter-api branch from 242649d to deb1b42 Compare November 6, 2023 15:32
This changes the API of the main class we're working with from
`SolidusFriendlyPromotions::OrderDiscounter` to
`SolidusFriendlyPromotions::FriendlyPromotionsAdjuster`. This class now
simply calls the three other (otherwise somewhat confusingly named)
service objects:

- `LoadPromotions`
- `DiscountOrder`
- `PersistDiscountedOrder`

This makes the code easier to read in my opinion, and simplifies the
API for promotion handlers significantly.
When we test whether a promotion is eligible, what we do is we perform a
dry run of the promotion adjuster. This change reflects that context in
the naming of our arguments.
This class suffered of unnecessary variables, and can also live with the
service classes for the FriendlyPromotionAdjuster.

It also could use a spec.
@mamhoff mamhoff force-pushed the refactor-discounter-api branch from deb1b42 to 4403912 Compare November 6, 2023 17:12
These are modules, and Rails offers a place for modules.
@mamhoff mamhoff merged commit 779a057 into main Nov 6, 2023
4 checks passed
@mamhoff mamhoff deleted the refactor-discounter-api branch November 6, 2023 17:28
mamhoff added a commit that referenced this pull request Jul 1, 2024
Refactor to FriendlyPromotion::FriendlyPromotionAdjuster
mamhoff added a commit that referenced this pull request Oct 25, 2024
Refactor to FriendlyPromotion::FriendlyPromotionAdjuster
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.

2 participants