Class: SpreeSquare::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/spree_square/engine.rb

Class Method Summary collapse

Class Method Details

.activateObject

Decorator files (app/models/spree/*_decorator.rb) intentionally define a constant Zeitwerk maps to their path (e.g. Spree::LineItemDecorator)

rather than something under the SpreeSquare

namespace — but with

eager_load off in development, nothing ever references that exact constant name, so lazy autoloading never triggers it and the SomeClass.prepend(...) line at the bottom of the file never runs. spree_core's own engine force-loads its decorators the same way (lib/spree/core/engine.rb) — each engine has to do this for its own app/ tree; there's no shared mechanism that covers extensions too.



57
58
59
60
61
# File 'lib/spree_square/engine.rb', line 57

def self.activate
  Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
    Rails.application.config.cache_classes ? require(c) : load(c)
  end
end