lib/ahoy_email/engine.rb in ahoy_email-0.5.1 vs lib/ahoy_email/engine.rb in ahoy_email-0.5.2
- old
+ new
@@ -1,13 +1,20 @@
require "rails/engine"
module AhoyEmail
class Engine < ::Rails::Engine
initializer "ahoy_email" do |app|
- # default to secrets to keep backward compatible
- ActiveSupport::Deprecation.silence do
- secrets = app.respond_to?(:secrets) ? app.secrets : app.config
- AhoyEmail.secret_token ||= secrets.respond_to?(:secret_key_base) ? secrets.secret_key_base : secrets.secret_token
+ AhoyEmail.secret_token ||= begin
+ creds =
+ if app.respond_to?(:credentials) && app.credentials.secret_key_base
+ app.credentials
+ elsif app.respond_to?(:secrets)
+ app.secrets
+ else
+ app.config
+ end
+
+ creds.respond_to?(:secret_key_base) ? creds.secret_key_base : creds.secret_token
end
AhoyEmail.belongs_to = {optional: true} if Rails::VERSION::MAJOR >= 5
end
end