diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-11-23 15:00:43 -0700 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-11-23 15:01:24 -0700 |
commit | 3faf7485623da55215d6d7f3dcb2eed92c59c699 (patch) | |
tree | 9af8983ba0576dd010f2d50797b76ef9e86cfa8c /actionmailer/lib | |
parent | de9b870f4026ce0eb40bf2a7dacbd137700910ef (diff) | |
download | rails-3faf7485623da55215d6d7f3dcb2eed92c59c699.tar.gz rails-3faf7485623da55215d6d7f3dcb2eed92c59c699.tar.bz2 rails-3faf7485623da55215d6d7f3dcb2eed92c59c699.zip |
Revert "Merge pull request #18446 from cloud8421/actionmailer-unregister-interceptor"
This reverts commit 65a61ab7c370d2894c11ce276725f723a5c9c111, reversing
changes made to 14314ca18302f18c3d8bb7a63e9f71ac4c2290c2.
This PR broke the build
Diffstat (limited to 'actionmailer/lib')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 39 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/preview.rb | 32 |
2 files changed, 19 insertions, 52 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 4c5d959e32..cbd7cec70f 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -441,8 +441,6 @@ module ActionMailer helper ActionMailer::MailHelper - private_class_method :find_class #:nodoc: - class_attribute :default_params self.default_params = { mime_version: "1.0", @@ -462,16 +460,16 @@ module ActionMailer interceptors.flatten.compact.each { |interceptor| register_interceptor(interceptor) } end - # Unregister one or more Interceptors which would be called before mail is sent. - def unregister_interceptors(*interceptors) - interceptors.flatten.compact.each { |interceptor| unregister_interceptor(interceptor) } - end - # Register an Observer which will be notified when mail is delivered. # Either a class, string or symbol can be passed in as the Observer. # If a string or symbol is passed in it will be camelized and constantized. def register_observer(observer) - delivery_observer = find_class(observer) + delivery_observer = case observer + when String, Symbol + observer.to_s.camelize.constantize + else + observer + end Mail.register_observer(delivery_observer) end @@ -480,20 +478,16 @@ module ActionMailer # Either a class, string or symbol can be passed in as the Interceptor. # If a string or symbol is passed in it will be camelized and constantized. def register_interceptor(interceptor) - delivery_interceptor = find_class(interceptor) + delivery_interceptor = case interceptor + when String, Symbol + interceptor.to_s.camelize.constantize + else + interceptor + end Mail.register_interceptor(delivery_interceptor) end - # Unregister a previously registered interceptor. - # Either a class, string or symbol can be passed in as the Interceptor. - # If a string or symbol is passed in it will be camelized and constantized. - def unregister_interceptor(interceptor) - delivery_interceptor = find_class(interceptor) - - Mail.unregister_interceptor(delivery_interceptor) - end - # Returns the name of current mailer. This method is also being used as a path for a view lookup. # If this is an anonymous mailer, this method will return +anonymous+ instead. def mailer_name @@ -847,15 +841,6 @@ module ActionMailer m end - def self.find_class(klass_or_string_or_symbol) - case klass_or_string_or_symbol - when String, Symbol - klass_or_string_or_symbol.to_s.camelize.constantize - else - klass_or_string_or_symbol - end - end - protected # Used by #mail to set the content type of the message. diff --git a/actionmailer/lib/action_mailer/preview.rb b/actionmailer/lib/action_mailer/preview.rb index 0b37f405ee..aab92fe8db 100644 --- a/actionmailer/lib/action_mailer/preview.rb +++ b/actionmailer/lib/action_mailer/preview.rb @@ -30,39 +30,21 @@ module ActionMailer interceptors.flatten.compact.each { |interceptor| register_preview_interceptor(interceptor) } end - # Unregister one or more previously registered Interceptors. - def unregister_preview_interceptors(*interceptors) - interceptors.flatten.compact.each { |interceptor| unregister_preview_interceptor(interceptor) } - end - # Register an Interceptor which will be called before mail is previewed. # Either a class or a string can be passed in as the Interceptor. If a # string is passed in it will be <tt>constantize</tt>d. def register_preview_interceptor(interceptor) - preview_interceptor = find_class(interceptor) + preview_interceptor = case interceptor + when String, Symbol + interceptor.to_s.camelize.constantize + else + interceptor + end + unless preview_interceptors.include?(preview_interceptor) preview_interceptors << preview_interceptor end end - - # Unregister a previously registered Interceptor. - # Either a class or a string can be passed in as the Interceptor. If a - # string is passed in it will be <tt>constantize</tt>d. - def unregister_preview_interceptor(interceptor) - preview_interceptor = find_class(interceptor) - preview_interceptors.delete(preview_interceptor) - end - - private - - def find_class(klass_or_string_or_symbol) #:nodoc: - case klass_or_string_or_symbol - when String, Symbol - klass_or_string_or_symbol.to_s.camelize.constantize - else - klass_or_string_or_symbol - end - end end end |