Skip to content

Commit

Permalink
Merge pull request #65 from waiting-for-dev/waiting-for-dev/fix_paths…
Browse files Browse the repository at this point in the history
…_depending_on_gem_order

Fix dependency on the engines load order when adding paths
  • Loading branch information
waiting-for-dev authored Jan 5, 2022
2 parents 09bfde4 + 202e77c commit 4dd0c05
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions lib/solidus_support/engine_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def self.included(engine)

config.to_prepare(&method(:activate))

enable_solidus_engine_support('backend') if SolidusSupport.backend_available?
enable_solidus_engine_support('frontend') if SolidusSupport.frontend_available?
enable_solidus_engine_support('api') if SolidusSupport.api_available?
enable_solidus_engine_support('backend')
enable_solidus_engine_support('frontend')
enable_solidus_engine_support('api')
end
end

Expand Down Expand Up @@ -82,17 +82,23 @@ def solidus_subscribers_root
#
# @see #load_solidus_decorators_from
def enable_solidus_engine_support(engine)
paths['app/controllers'] << "lib/controllers/#{engine}"
paths['app/views'] << "lib/views/#{engine}"
initializer "#{name}_#{engine}_paths", before: :initialize_dependency_mechanism do
if SolidusSupport.send(:"#{engine}_available?")
paths['app/controllers'] << "lib/controllers/#{engine}"
paths['app/views'] << "lib/views/#{engine}"
end
end

path = root.join("lib/decorators/#{engine}")
if SolidusSupport.send(:"#{engine}_available?")
path = root.join("lib/decorators/#{engine}")

config.autoload_paths += path.glob('*')
config.autoload_paths += path.glob('*')

engine_context = self
config.to_prepare do
engine_context.instance_eval do
load_solidus_decorators_from(path)
engine_context = self
config.to_prepare do
engine_context.instance_eval do
load_solidus_decorators_from(path)
end
end
end
end
Expand Down

0 comments on commit 4dd0c05

Please sign in to comment.