lib/action_mailer/preview.rb in actionmailer-5.0.7.2 vs lib/action_mailer/preview.rb in actionmailer-5.1.0.beta1

- old
+ new

@@ -1,6 +1,6 @@ -require 'active_support/descendants_tracker' +require "active_support/descendants_tracker" module ActionMailer module Previews #:nodoc: extend ActiveSupport::Concern @@ -32,11 +32,12 @@ # 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 + preview_interceptor = \ + case interceptor when String, Symbol interceptor.to_s.camelize.constantize else interceptor end @@ -60,11 +61,11 @@ # Returns the mail object for the given email name. The registered preview # interceptors will be informed so that they can transform the message # as they would if the mail was actually being delivered. def call(email) - preview = self.new + preview = new message = preview.public_send(email) inform_preview_interceptors(message) message end @@ -78,38 +79,38 @@ emails.include?(email) end # Returns true if the preview exists. def exists?(preview) - all.any?{ |p| p.preview_name == preview } + all.any? { |p| p.preview_name == preview } end # Find a mailer preview by its underscored class name. def find(preview) - all.find{ |p| p.preview_name == preview } + all.find { |p| p.preview_name == preview } end # Returns the underscored name of the mailer preview without the suffix. def preview_name - name.sub(/Preview$/, '').underscore + name.sub(/Preview$/, "").underscore end - protected - def load_previews #:nodoc: + private + def load_previews if preview_path - Dir["#{preview_path}/**/*_preview.rb"].each{ |file| require_dependency file } + Dir["#{preview_path}/**/*_preview.rb"].each { |file| require_dependency file } end end - def preview_path #:nodoc: + def preview_path Base.preview_path end - def show_previews #:nodoc: + def show_previews Base.show_previews end - def inform_preview_interceptors(message) #:nodoc: + def inform_preview_interceptors(message) Base.preview_interceptors.each do |interceptor| interceptor.previewing_email(message) end end end