Sha256: 22ec30ce00485748f03f7a6ef0ad5b5eecd1fb5bb0c68523b82d94ba43ef551f
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module SolidusSupport module EngineExtensions module Decorators def self.included(engine) engine.class_eval do extend ClassMethods config.to_prepare(&method(:activate).to_proc) end end module ClassMethods def activate base_path = root.join('app/decorators') if Rails.respond_to?(:autoloaders) && Rails.autoloaders.main # Add decorators folder to the Rails autoloader. This # allows Zeitwerk to resolve decorators paths correctly, # when used. Dir.glob(base_path.join('*')) do |decorators_folder| Rails.autoloaders.main.push_dir(decorators_folder) end end # Load decorator files. This is needed since they are # never explicitely referenced in the application code # and won't be loaded by default. We need them to be # executed anyway to extend exisiting classes. Dir.glob(base_path.join('**/*.rb')) do |decorator_path| require_dependency(decorator_path) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_support-0.4.1 | lib/solidus_support/engine_extensions/decorators.rb |