Skip to content

Commit

Permalink
Merge pull request #47 from nebulab/spaghetticode/check-for-events
Browse files Browse the repository at this point in the history
Load event subscribers only when Spree::Event is available
  • Loading branch information
aldesantis authored Jun 5, 2020
2 parents b4629c3 + 7764ae0 commit 540b4f6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/solidus_support/engine_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ def activate
# This allows to add event subscribers to extensions without explicitly subscribing them,
# similarly to what happens in Solidus core.
def load_solidus_subscribers_from(path)
path.glob("**/*_subscriber.rb") do |subscriber_path|
require_dependency(subscriber_path)
if defined? Spree::Event
path.glob("**/*_subscriber.rb") do |subscriber_path|
require_dependency(subscriber_path)
end
Spree::Event.subscribers.each(&:subscribe!)
end
Spree::Event.subscribers.each(&:subscribe!)
end

# Loads decorator files.
Expand Down

0 comments on commit 540b4f6

Please sign in to comment.