Skip to content

Commit 7d86352

Browse files
committed
Don't use a class_attribute for ActionMailer::Base.preview_path
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.
1 parent 35fd816 commit 7d86352

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

actionmailer/lib/action_mailer/preview.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Previews #:nodoc:
99
#
1010
# config.action_mailer.preview_path = "#{Rails.root}/lib/mailer_previews"
1111
#
12-
class_attribute :preview_path, instance_writer: false
12+
mattr_accessor :preview_path, instance_writer: false
1313

1414
# :nodoc:
1515
mattr_accessor :preview_interceptors, instance_writer: false
@@ -85,7 +85,7 @@ def preview_name
8585

8686
protected
8787
def load_previews #:nodoc:
88-
if preview_path?
88+
if preview_path
8989
Dir["#{preview_path}/**/*_preview.rb"].each{ |file| require_dependency file }
9090
end
9191
end
@@ -94,10 +94,6 @@ def preview_path #:nodoc:
9494
Base.preview_path
9595
end
9696

97-
def preview_path? #:nodoc:
98-
Base.preview_path?
99-
end
100-
10197
def inform_preview_interceptors(message) #:nodoc:
10298
Base.preview_interceptors.each do |interceptor|
10399
interceptor.previewing_email(message)

actionmailer/lib/action_mailer/railtie.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Railtie < Rails::Railtie # :nodoc:
4646
end
4747

4848
config.after_initialize do
49-
if ActionMailer::Base.preview_path?
49+
if ActionMailer::Base.preview_path
5050
ActiveSupport::Dependencies.autoload_paths << ActionMailer::Base.preview_path
5151
end
5252
end

0 commit comments

Comments
 (0)