lib/mailkick.rb in mailkick-0.1.1 vs lib/mailkick.rb in mailkick-0.1.2

- old
+ new

@@ -5,21 +5,20 @@ require "mailkick/model" require "mailkick/service" require "mailkick/service/mailchimp" require "mailkick/service/mandrill" require "mailkick/service/sendgrid" +require "mailkick/service/mailgun" require "set" module Mailkick mattr_accessor :services, :user_method, :secret_token self.services = [] - self.user_method = proc{|email| User.where(email: email).first rescue nil } + self.user_method = proc { |email| User.where(email: email).first rescue nil } def self.fetch_opt_outs - services.each do |service| - service.fetch_opt_outs - end + services.each(&:fetch_opt_outs) end def self.discover_services Service.subclasses.each do |service| if service.discoverable? @@ -31,11 +30,11 @@ def self.opted_out?(options) opt_outs(options).any? end def self.opt_out(options) - if !opted_out?(options) + unless opted_out?(options) time = options[:time] || Time.now Mailkick::OptOut.create! do |o| o.email = options[:email] o.user = options[:user] o.reason = options[:reason] || "unsubscribe" @@ -88,10 +87,9 @@ # does not take into account emails def self.opted_out_users(options = {}) Set.new(opt_outs(options).where("user_id IS NOT NULL").map(&:user)) end - end ActionMailer::Base.send :include, Mailkick::Mailer ActiveRecord::Base.send(:extend, Mailkick::Model) if defined?(ActiveRecord)