From e75fd205cbeae45a056f52bc0932e2c53edc7fb2 Mon Sep 17 00:00:00 2001 From: wjwitek Date: Fri, 10 Feb 2023 10:03:33 +0100 Subject: [PATCH 1/2] move functions checking for gem availability to core --- lib/spree/auth/engine.rb | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/lib/spree/auth/engine.rb b/lib/spree/auth/engine.rb index 01ed4480..2cb4fdc4 100644 --- a/lib/spree/auth/engine.rb +++ b/lib/spree/auth/engine.rb @@ -1,11 +1,14 @@ require 'devise' require 'devise-encryptable' +require 'pry' require_relative 'configuration' module Spree module Auth class Engine < Rails::Engine + include Spree::Core::ControllerHelpers::GemChecking + isolate_namespace Spree engine_name 'spree_auth' @@ -30,17 +33,17 @@ def self.activate Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c| Rails.configuration.cache_classes ? require(c) : load(c) end - if Spree::Auth::Engine.backend_available? + if backend_available? Dir.glob(File.join(File.dirname(__FILE__), "../../controllers/backend/*/*/*_decorator*.rb")) do |c| Rails.configuration.cache_classes ? require(c) : load(c) end end - if Spree::Auth::Engine.frontend_available? + if frontend_available? Dir.glob(File.join(File.dirname(__FILE__), "../../controllers/frontend/**/*_decorator*.rb")) do |c| Rails.configuration.cache_classes ? require(c) : load(c) end end - if Spree::Auth::Engine.api_available? + if api_available? Dir.glob(File.join(File.dirname(__FILE__), "../../controllers/api/**/*_decorator*.rb")) do |c| Rails.configuration.cache_classes ? require(c) : load(c) end @@ -48,26 +51,6 @@ def self.activate ApplicationController.send :include, Spree::AuthenticationHelpers end - def self.api_available? - @@api_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Api::Engine') - end - - def self.backend_available? - @@backend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Backend::Engine') - end - - def self.frontend_available? - @@frontend_available ||= Gem::Specification.find_all_by_name('spree_frontend').any? - end - - def self.api_available? - @@api_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Api::Engine') - end - - def self.emails_available? - @@emails_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Emails::Engine') - end - if backend_available? paths["app/controllers"] << "lib/controllers/backend" paths["app/views"] << "lib/views/backend" From 8c0f87f6be311d9aee870064da7661cd2307d1e3 Mon Sep 17 00:00:00 2001 From: wjwitek Date: Fri, 10 Feb 2023 10:57:36 +0100 Subject: [PATCH 2/2] remove pry --- lib/spree/auth/engine.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/spree/auth/engine.rb b/lib/spree/auth/engine.rb index 2cb4fdc4..250b3612 100644 --- a/lib/spree/auth/engine.rb +++ b/lib/spree/auth/engine.rb @@ -1,6 +1,5 @@ require 'devise' require 'devise-encryptable' -require 'pry' require_relative 'configuration'