Permalink
Browse files

Removed reliance on mynyml's override gem.

  • Loading branch information...
1 parent 7011764 commit 1f50d8330259003ae65046b574a91cfd4ade7b3e @myronmarston committed Mar 14, 2010
Showing with 25 additions and 20 deletions.
  1. +1 −2 Rakefile
  2. +24 −18 lib/email_blacklist.rb
View
@@ -10,8 +10,7 @@ begin
gem.email = "myron.marston@gmail.com"
gem.homepage = "http://github.com/myronmarston/email_blacklist"
gem.authors = ["Myron Marston"]
- gem.add_dependency 'mynyml-override'
- gem.add_dependency 'actionmailer'
+ gem.add_dependency 'actionmailer', '>= 1.3.6'
gem.add_development_dependency "rspec", ">= 1.2.9"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
@@ -1,5 +1,4 @@
require 'action_mailer'
-require 'override'
module EmailBlacklist
ADDRESS_TYPES = [:to, :cc, :bcc].freeze
@@ -18,24 +17,31 @@ def blacklisted?(email_address)
end
end
end
-end
-
-ActionMailer::Base.class_eval do
- override :deliver!
- def deliver!(mail = @mail)
- if mail
- all_addresses = []
-
- EmailBlacklist::ADDRESS_TYPES.each do |address_type|
- addresses = mail.send(address_type)
- addresses.reject! { |a| EmailBlacklist::Config.blacklisted?(a) } if addresses
- all_addresses << addresses
- mail.send("#{address_type}=", addresses)
- end
- return mail if all_addresses.flatten.compact.empty?
+ module ActionMailer
+ def new(*args, &block)
+ super.extend Extension
end
- super(mail)
+ module Extension
+ def deliver!(mail = @mail)
+ if mail
+ all_addresses = []
+
+ EmailBlacklist::ADDRESS_TYPES.each do |address_type|
+ addresses = mail.send(address_type)
+ addresses.reject! { |a| EmailBlacklist::Config.blacklisted?(a) } if addresses
+ all_addresses << addresses
+ mail.send("#{address_type}=", addresses)
+ end
+
+ return mail if all_addresses.flatten.compact.empty?
+ end
+
+ super(mail)
+ end
+ end
end
-end
+end
+
+ActionMailer::Base.extend EmailBlacklist::ActionMailer

0 comments on commit 1f50d83

Please sign in to comment.