-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
add functions that check for availaibility of spree components like b… #11847
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,26 @@ | ||||||
module Spree | ||||||
module Core | ||||||
module ControllerHelpers | ||||||
module GemChecking | ||||||
extend ActiveSupport::Concern | ||||||
|
||||||
def backend_available? | ||||||
@backend_available ||= Gem::Specification.find_all_by_name('spree_backend').any? | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can also do:
Suggested change
But regardless, there is a potential issue here I think - this will return This shouldn't be an issue for most cases but I wouldn't be surprised if it yields something unexpected for some obscure use case. Probably that's why originally the functions checked whether the engines were loaded. WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the moment it's done using: |
||||||
end | ||||||
|
||||||
def frontend_available? | ||||||
@frontend_available ||= Gem::Specification.find_all_by_name('spree_frontend').any? | ||||||
end | ||||||
|
||||||
def api_available? | ||||||
@api_available ||= Gem::Specification.find_all_by_name('spree_api').any? | ||||||
end | ||||||
|
||||||
def emails_available? | ||||||
@emails_available ||= Gem::Specification.find_all_by_name('spree_emails').any? | ||||||
end | ||||||
end | ||||||
end | ||||||
end | ||||||
end | ||||||
|
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.
Maybe a name like
ComponentAvailability
(I don't like this one 100% but maybe there's something similar) would be more clear here?