From 7d86352f83079458dd04df2ee5e1b38179c3aac3 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Sun, 26 Jan 2014 11:50:36 +0000 Subject: Don't use a class_attribute for ActionMailer::Base.preview_path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since preview_path is read from ActionMailer::Base when previewing, subclasses can’t change it so don’t there's no need for the extra overhead imposed by using it. --- actionmailer/lib/action_mailer/preview.rb | 8 ++------ actionmailer/lib/action_mailer/railtie.rb | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/preview.rb b/actionmailer/lib/action_mailer/preview.rb index 0efd702e4d..fde0e86f5b 100644 --- a/actionmailer/lib/action_mailer/preview.rb +++ b/actionmailer/lib/action_mailer/preview.rb @@ -9,7 +9,7 @@ module ActionMailer # # config.action_mailer.preview_path = "#{Rails.root}/lib/mailer_previews" # - class_attribute :preview_path, instance_writer: false + mattr_accessor :preview_path, instance_writer: false # :nodoc: mattr_accessor :preview_interceptors, instance_writer: false @@ -85,7 +85,7 @@ module ActionMailer protected def load_previews #:nodoc: - if preview_path? + if preview_path Dir["#{preview_path}/**/*_preview.rb"].each{ |file| require_dependency file } end end @@ -94,10 +94,6 @@ module ActionMailer Base.preview_path end - def preview_path? #:nodoc: - Base.preview_path? - end - def inform_preview_interceptors(message) #:nodoc: Base.preview_interceptors.each do |interceptor| interceptor.previewing_email(message) diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index c893ddfef5..8d1e40297b 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -46,7 +46,7 @@ module ActionMailer end config.after_initialize do - if ActionMailer::Base.preview_path? + if ActionMailer::Base.preview_path ActiveSupport::Dependencies.autoload_paths << ActionMailer::Base.preview_path end end -- cgit v1.2.3