How to make Wisper properly load all subscribers in the app/subscribers directory structure
Rails.application.reloader.to_prepare do
# Dev env will re-install subscribers on app reload
Wisper.clear if Rails.env.development?
Dir[Rails.root.join("app", "subscribers", "**", "*.rb")].each do |listener|
relative_path = listener.gsub("#{Rails.root}/app/subscribers/", "")
klass = relative_path.chomp(".rb").camelize.safe_constantize
Wisper.subscribe(klass.new, async: !Rails.env.test?)
end
end
Sharing since the sample provided by the project itself won't work with namespaced subscribers.