Module: SolidusSupport::EngineExtensions::ClassMethods
- Defined in:
- lib/solidus_support/engine_extensions.rb
Instance Method Summary collapse
- #activate ⇒ Object
-
#load_solidus_decorators_from(path) ⇒ Object
Loads decorator files.
-
#load_solidus_subscribers_from(path) ⇒ Object
Loads Solidus event subscriber files.
Instance Method Details
#activate ⇒ Object
26 27 28 29 |
# File 'lib/solidus_support/engine_extensions.rb', line 26 def activate load_solidus_decorators_from(solidus_decorators_root) load_solidus_subscribers_from(solidus_subscribers_root) end |
#load_solidus_decorators_from(path) ⇒ Object
Loads decorator files.
This is needed since they are never explicitly referenced in the application code and won’t be loaded by default. We need them to be executed regardless in order to decorate existing classes.
49 50 51 52 53 |
# File 'lib/solidus_support/engine_extensions.rb', line 49 def load_solidus_decorators_from(path) path.glob('**/*.rb') do |decorator_path| require_dependency(decorator_path) end end |
#load_solidus_subscribers_from(path) ⇒ Object
Loads Solidus event subscriber files.
This allows to add event subscribers to extensions without explicitly subscribing them, similarly to what happens in Solidus core.
35 36 37 38 39 40 41 42 |
# File 'lib/solidus_support/engine_extensions.rb', line 35 def load_solidus_subscribers_from(path) if defined? Spree::Event path.glob("**/*_subscriber.rb") do |subscriber_path| require_dependency(subscriber_path) end Spree::Event.subscribers.each(&:subscribe!) end end |