Skip to content

Commit

Permalink
Use Spree::Event.activate_all_subscribers when available
Browse files Browse the repository at this point in the history
The new method `Spree::Event.activate_all_subscribers` is introduced
in Solidus with solidusio/solidus#3758 as a better way to subscribe
event subscribers. Under the hood, event subscribers use new interal
mappings.

Also, we need to keep around the old interface as well until it won't
be supported anymore in Solidus.
  • Loading branch information
spaghetticode committed Oct 19, 2020
1 parent 1f2b80b commit 5b52ea7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/solidus_support/engine_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ def load_solidus_subscribers_from(path)
path.glob("**/*_subscriber.rb") do |subscriber_path|
require_dependency(subscriber_path)
end
Spree::Event.subscribers.each(&:subscribe!)

if Spree::Event.respond_to?(:activate_all_subscribers)
Spree::Event.activate_all_subscribers
else
Spree::Event.subscribers.each(&:subscribe!)
end
end
end

Expand Down

0 comments on commit 5b52ea7

Please sign in to comment.