-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Remove benefit "level" mixins #6378
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
Conversation
e0420a1 to
20edc22
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6378 +/- ##
==========================================
- Coverage 89.46% 89.46% -0.01%
==========================================
Files 977 977
Lines 20350 20386 +36
==========================================
+ Hits 18207 18238 +31
- Misses 2143 2148 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
20edc22 to
54f5816
Compare
54f5816 to
aa37ca8
Compare
tvdeyen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work. Ruby is a meta programming super star.
TIL inherited and method_added.
adammathys
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one small typo.
Similar to the work in solidusio#6360, this improves the DSL for creating benefits. Rather than having to define one method that cares for applicability to a discountable, we now simply define that a benefit `#can_discount?` an object if its public interface has `#discount_{discountable_type}` defined. This does not change the implementation of the different methods, but that will come when we refactor the promotion system to use a single system of record for discounts. Then, different objects will need different discount records (line items and shipment use adjustments, but shipping rates use shipping rate discounts etc.). I'm not doing the work for adding deprecation warnings here, as this code was never meant to be overridden up to now. Also fixes some AI slop in the docs.
Instead, follow the deprecation message's instructions.
In the unlikely case people have used these modules, warn if they are included.
aa37ca8 to
a0ab878
Compare
Summary
This applies the same refactoring that was done in #6360 to benefits, which have a similar API (they only discount when they can discount, the same way conditions only check eligibility if they are applicable).
This work is extracted from #6371. If we get this in earlier, that work gets easier to review.
Note that I have
notgone to the trouble to add deprecation warnings here.If anyone can show me real-world code that has actually created new benefits and that would benefit from a deprecation warning, I'll happily add them.Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: