diff options
Diffstat (limited to 'actionmailer/lib/action_mailer/base.rb')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index cbd7cec70f..4c5d959e32 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -441,6 +441,8 @@ module ActionMailer helper ActionMailer::MailHelper + private_class_method :find_class #:nodoc: + class_attribute :default_params self.default_params = { mime_version: "1.0", @@ -460,16 +462,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 = case observer - when String, Symbol - observer.to_s.camelize.constantize - else - observer - end + delivery_observer = find_class(observer) Mail.register_observer(delivery_observer) end @@ -478,16 +480,20 @@ 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 = case interceptor - when String, Symbol - interceptor.to_s.camelize.constantize - else - interceptor - end + delivery_interceptor = find_class(interceptor) 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 @@ -841,6 +847,15 @@ 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. |