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

- old
+ new

@@ -1,8 +1,7 @@ module Mailkick module Model - def mailkick_user(options = {}) email_key = options[:email_key] || :email class_eval do scope :opted_out, proc {|options = {}| binds = [self.class.name, true] @@ -10,11 +9,11 @@ query = "(mailkick_opt_outs.list IS NULL OR mailkick_opt_outs.list = ?)" binds << options[:list] else query = "mailkick_opt_outs.list IS NULL" end - where("#{options[:not] ? "NOT " : ""}EXISTS(SELECT * FROM mailkick_opt_outs WHERE (#{table_name}.#{email_key} = mailkick_opt_outs.email OR (#{table_name}.#{primary_key} = mailkick_opt_outs.user_id AND mailkick_opt_outs.user_type = ?)) AND mailkick_opt_outs.active = ? AND #{query})", *binds) + where("#{options[:not] ? 'NOT ' : ''}EXISTS(SELECT * FROM mailkick_opt_outs WHERE (#{table_name}.#{email_key} = mailkick_opt_outs.email OR (#{table_name}.#{primary_key} = mailkick_opt_outs.user_id AND mailkick_opt_outs.user_type = ?)) AND mailkick_opt_outs.active = ? AND #{query})", *binds) } scope :not_opted_out, proc {|options = {}| opted_out(options.merge(not: true)) } @@ -27,11 +26,9 @@ end def opt_in(options = {}) Mailkick.opt_in({email: email, user: self}.merge(options)) end - end end - end end