aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib/action_mailer/preview.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionmailer/lib/action_mailer/preview.rb')
-rw-r--r--actionmailer/lib/action_mailer/preview.rb32
1 files changed, 25 insertions, 7 deletions
diff --git a/actionmailer/lib/action_mailer/preview.rb b/actionmailer/lib/action_mailer/preview.rb
index 44cf6665ba..6fd3b0b120 100644
--- a/actionmailer/lib/action_mailer/preview.rb
+++ b/actionmailer/lib/action_mailer/preview.rb
@@ -30,21 +30,39 @@ 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 = case interceptor
- when String, Symbol
- interceptor.to_s.camelize.constantize
- else
- interceptor
- end
-
+ preview_interceptor = find_class(interceptor)
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