lib/ahoy_email.rb in ahoy_email-0.5.0 vs lib/ahoy_email.rb in ahoy_email-0.5.1

- old
+ new

@@ -1,16 +1,15 @@ -require "ahoy_email/version" -require "action_mailer" -require "rails" +require "active_support" require "nokogiri" require "addressable/uri" require "openssl" require "safely/core" require "ahoy_email/processor" require "ahoy_email/interceptor" require "ahoy_email/mailer" require "ahoy_email/engine" +require "ahoy_email/version" module AhoyEmail mattr_accessor :secret_token, :options, :subscribers, :belongs_to, :invalid_redirect_url self.options = { @@ -39,11 +38,15 @@ class << self attr_writer :message_model end def self.message_model - (defined?(@message_model) && @message_model) || ::Ahoy::Message + model = (defined?(@message_model) && @message_model) || ::Ahoy::Message + model = model.call if model.respond_to?(:call) + model end end -ActionMailer::Base.send :include, AhoyEmail::Mailer -ActionMailer::Base.register_interceptor AhoyEmail::Interceptor +ActiveSupport.on_load(:action_mailer) do + include AhoyEmail::Mailer + register_interceptor AhoyEmail::Interceptor +end