1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Privatize unneededly protected methods in Action Mailer

This commit is contained in:
Akira Matsuda 2016-12-22 18:57:02 +09:00
parent bbbc3e1619
commit 8c7e82e8e0
4 changed files with 20 additions and 27 deletions

View file

@ -544,9 +544,9 @@ module ActionMailer
end end
end end
protected private
def set_payload_for_mail(payload, mail) #:nodoc: def set_payload_for_mail(payload, mail)
payload[:mailer] = name payload[:mailer] = name
payload[:message_id] = mail.message_id payload[:message_id] = mail.message_id
payload[:subject] = mail.subject payload[:subject] = mail.subject
@ -558,7 +558,7 @@ module ActionMailer
payload[:mail] = mail.encoded payload[:mail] = mail.encoded
end end
def method_missing(method_name, *args) # :nodoc: def method_missing(method_name, *args)
if action_methods.include?(method_name.to_s) if action_methods.include?(method_name.to_s)
MessageDelivery.new(self, method_name, *args) MessageDelivery.new(self, method_name, *args)
else else
@ -566,8 +566,6 @@ module ActionMailer
end end
end end
private
def respond_to_missing?(method, include_all = false) def respond_to_missing?(method, include_all = false)
action_methods.include?(method.to_s) action_methods.include?(method.to_s)
end end
@ -830,7 +828,7 @@ module ActionMailer
message message
end end
protected private
# Used by #mail to set the content type of the message. # Used by #mail to set the content type of the message.
# #
@ -841,7 +839,7 @@ module ActionMailer
# If there is no content type passed in via headers, and there are no # If there is no content type passed in via headers, and there are no
# attachments, or the message is multipart, then the default content type is # attachments, or the message is multipart, then the default content type is
# used. # used.
def set_content_type(m, user_content_type, class_default) def set_content_type(m, user_content_type, class_default) # :doc:
params = m.content_type_parameters || {} params = m.content_type_parameters || {}
case case
when user_content_type.present? when user_content_type.present?
@ -863,18 +861,16 @@ module ActionMailer
# If it does not find a translation for the +subject+ under the specified scope it will default to a # If it does not find a translation for the +subject+ under the specified scope it will default to a
# humanized version of the <tt>action_name</tt>. # humanized version of the <tt>action_name</tt>.
# If the subject has interpolations, you can pass them through the +interpolations+ parameter. # If the subject has interpolations, you can pass them through the +interpolations+ parameter.
def default_i18n_subject(interpolations = {}) def default_i18n_subject(interpolations = {}) # :doc:
mailer_scope = self.class.mailer_name.tr("/", ".") mailer_scope = self.class.mailer_name.tr("/", ".")
I18n.t(:subject, interpolations.merge(scope: [mailer_scope, action_name], default: action_name.humanize)) I18n.t(:subject, interpolations.merge(scope: [mailer_scope, action_name], default: action_name.humanize))
end end
# Emails do not support relative path links. # Emails do not support relative path links.
def self.supports_path? def self.supports_path? # :doc:
false false
end end
private
def apply_defaults(headers) def apply_defaults(headers)
default_values = self.class.default.map do |key, value| default_values = self.class.default.map do |key, value|
[ [

View file

@ -94,22 +94,22 @@ module ActionMailer
name.sub(/Preview$/, "").underscore name.sub(/Preview$/, "").underscore
end end
protected private
def load_previews #:nodoc: def load_previews
if preview_path 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
end end
def preview_path #:nodoc: def preview_path
Base.preview_path Base.preview_path
end end
def show_previews #:nodoc: def show_previews
Base.show_previews Base.show_previews
end end
def inform_preview_interceptors(message) #:nodoc: def inform_preview_interceptors(message)
Base.preview_interceptors.each do |interceptor| Base.preview_interceptors.each do |interceptor|
interceptor.previewing_email(message) interceptor.previewing_email(message)
end end

View file

@ -73,38 +73,36 @@ module ActionMailer
end end
end end
protected private
def initialize_test_deliveries # :nodoc: def initialize_test_deliveries
set_delivery_method :test set_delivery_method :test
@old_perform_deliveries = ActionMailer::Base.perform_deliveries @old_perform_deliveries = ActionMailer::Base.perform_deliveries
ActionMailer::Base.perform_deliveries = true ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
end end
def restore_test_deliveries # :nodoc: def restore_test_deliveries
restore_delivery_method restore_delivery_method
ActionMailer::Base.perform_deliveries = @old_perform_deliveries ActionMailer::Base.perform_deliveries = @old_perform_deliveries
end end
def set_delivery_method(method) # :nodoc: def set_delivery_method(method)
@old_delivery_method = ActionMailer::Base.delivery_method @old_delivery_method = ActionMailer::Base.delivery_method
ActionMailer::Base.delivery_method = method ActionMailer::Base.delivery_method = method
end end
def restore_delivery_method # :nodoc: def restore_delivery_method
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
ActionMailer::Base.delivery_method = @old_delivery_method ActionMailer::Base.delivery_method = @old_delivery_method
end end
def set_expected_mail # :nodoc: def set_expected_mail
@expected = Mail.new @expected = Mail.new
@expected.content_type ["text", "plain", { "charset" => charset }] @expected.content_type ["text", "plain", { "charset" => charset }]
@expected.mime_version = "1.0" @expected.mime_version = "1.0"
end end
private
def charset def charset
"UTF-8" "UTF-8"
end end

View file

@ -19,12 +19,11 @@ module Rails
hook_for :template_engine, :test_framework hook_for :template_engine, :test_framework
protected private
def file_name def file_name # :doc:
@_file_name ||= super.gsub(/_mailer/i, "") @_file_name ||= super.gsub(/_mailer/i, "")
end end
private
def application_mailer_file_name def application_mailer_file_name
@_application_mailer_file_name ||= if mountable_engine? @_application_mailer_file_name ||= if mountable_engine?
"app/mailers/#{namespaced_path}/application_mailer.rb" "app/mailers/#{namespaced_path}/application_mailer.rb"