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

Allow dev mode code reloading of configured classes #2126

Merged
merged 2 commits into from
Aug 23, 2017

Conversation

jhawthorn
Copy link
Contributor

Previously if a change was made to one of the classes configured in Spree::Config, the changes wouldn't apply until the development server was restarted. This is because we stored a reference to the exact class, and it would not use the new version of the class loaded by code reloading.

This PR changes the attributes to store the class name, and to #constantize it when accessed. This is similar to the change made in #1203 to the arrays of classes for calculators, payment methods, etc.

@jhawthorn jhawthorn force-pushed the class_name_attribute branch from 2a9d7c0 to 23de93c Compare July 31, 2017 20:45
@kennyadsl
Copy link
Member

I don't know this topic very well but I'm curious why we didn't used the Rails class_attribute here. It should also have a default option now.

@jhawthorn
Copy link
Contributor Author

I don't know this topic very well but I'm curious why we didn't used the Rails class_attribute here. It should also have a default option now.

The purpose of this is to call constantize whenever accessed

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Do we need any spec for this method?

Copy link
Contributor

@mamhoff mamhoff left a comment

Choose a reason for hiding this comment

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

I think existing specs for the class name attributes (Spree::Config.searcher_class) et al. sufficiently test the method.

@mamhoff mamhoff merged commit 753cc7c into solidusio:master Aug 23, 2017
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.

4 participants