-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Use Flickwerk for loading patches in solidus_promotions and solidus_legacy_promotions #6049
base: main
Are you sure you want to change the base?
Conversation
e3a6541
to
cd8ae9f
Compare
When configuring Flickwerk, we need a way to get at class names without constantizing (i.e. loading) those classes. This adds some specs for the `class_name_attribute` class method on Spree::Preferences::Configuration, and generates a new getter that has `_name` attached to the method to get just the string name.
This stops us from loading line item, order, adjustment, shipment, shipping rate, and the order recalculator on app startup.
This should stop us from loading order, line items, adjustment, calculators, the order updater, product, and shipment on app startup.
cd8ae9f
to
f8b3503
Compare
|
||
initializer "solidus_legacy_promotions.patch_state_machine" do | ||
config.to_prepare do | ||
SolidusLegacyPromotions::SpreeOrderStateMachinePatch |
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.
Can you explain why this is necessary?
|
||
initializer "solidus_legacy_promotions.patch_state_machine" do | ||
config.to_prepare do | ||
SolidusLegacyPromotions::SpreeOrderStateMachinePatch |
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.
This is necessary because Spree::StateMachines::Order
is defined in lib
and not autoloaded, so that Flickwerk's on_load
hook won't do the trick.
Waits until #6056 got merged |
Summary
Uses the Flickwerk gem to load patches in the solidus_promotions and solidus_legacy_promotions gems.
This allows us to defer loading of patches to when the classes being patched are autoloaded, rather than loading them in a
config.to_prepare
block.The commit history should explain the few things I had to add here. Namely, I had to add a getter to
Spree::Preferences::Configuration
for the class names of configurable classes in order to configure Flickwerk to be able to understand patches likeSpree::Config.order_recalculator_class.prepend self
.Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: