From 797e1746b6b5d5a0d806af3ffa14c6cdf0a34dc1 Mon Sep 17 00:00:00 2001 From: nciemniak Date: Fri, 25 Nov 2022 15:23:33 +0100 Subject: [PATCH] Unify method for checking for spree gems --- lib/spree/auth/engine.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/spree/auth/engine.rb b/lib/spree/auth/engine.rb index ecd923be..181fdc32 100644 --- a/lib/spree/auth/engine.rb +++ b/lib/spree/auth/engine.rb @@ -49,23 +49,19 @@ def self.activate end def self.api_available? - @@api_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Api::Engine') + @@api_available ||= Gem::Specification.find_all_by_name('spree').any? end def self.backend_available? - @@backend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Backend::Engine') + @@backend_available ||= Gem::Specification.find_all_by_name('spree_backend').any? end def self.frontend_available? - @@frontend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Frontend::Engine') - end - - def self.api_available? - @@api_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Api::Engine') + @@frontend_available ||= Gem::Specification.find_all_by_name('spree_frontend').any? end def self.emails_available? - @@emails_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Emails::Engine') + @@emails_available ||= Gem::Specification.find_all_by_name('spree_emails').any? end if backend_available?