lib/mailkick.rb in mailkick-0.1.5 vs lib/mailkick.rb in mailkick-0.1.6
- old
+ new
@@ -1,17 +1,18 @@
-require "mailkick/version"
-require "mailkick/engine"
+require "set"
+require "safely/core"
+require "active_support"
+require "mailkick/engine" if defined?(Rails)
require "mailkick/processor"
require "mailkick/mailer"
require "mailkick/model"
require "mailkick/service"
require "mailkick/service/mailchimp"
require "mailkick/service/mandrill"
require "mailkick/service/sendgrid"
require "mailkick/service/mailgun"
-require "set"
-require "safely/core"
+require "mailkick/version"
module Mailkick
mattr_accessor :services, :user_method, :secret_token, :mount
self.services = []
self.user_method = proc { |email| User.where(email: email).first rescue nil }
@@ -87,7 +88,12 @@
def self.opted_out_users(options = {})
Set.new(opt_outs(options).where("user_id IS NOT NULL").map(&:user))
end
end
-ActionMailer::Base.send(:prepend, Mailkick::Mailer)
-ActiveRecord::Base.send(:extend, Mailkick::Model) if defined?(ActiveRecord)
+ActiveSupport.on_load(:action_mailer) do
+ prepend Mailkick::Mailer
+end
+
+ActiveSupport.on_load(:active_record) do
+ extend Mailkick::Model
+end