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
protected
private
def set_payload_for_mail(payload, mail) #:nodoc:
def set_payload_for_mail(payload, mail)
payload[:mailer] = name
payload[:message_id] = mail.message_id
payload[:subject] = mail.subject
@ -558,7 +558,7 @@ module ActionMailer
payload[:mail] = mail.encoded
end
def method_missing(method_name, *args) # :nodoc:
def method_missing(method_name, *args)
if action_methods.include?(method_name.to_s)
MessageDelivery.new(self, method_name, *args)
else
@ -566,8 +566,6 @@ module ActionMailer
end
end
private
def respond_to_missing?(method, include_all = false)
action_methods.include?(method.to_s)
end
@ -830,7 +828,7 @@ module ActionMailer
message
end
protected
private
# 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
# attachments, or the message is multipart, then the default content type is
# 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 || {}
case
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
# humanized version of the <tt>action_name</tt>.
# 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("/", ".")
I18n.t(:subject, interpolations.merge(scope: [mailer_scope, action_name], default: action_name.humanize))
end
# Emails do not support relative path links.
def self.supports_path?
def self.supports_path? # :doc:
false
end
private
def apply_defaults(headers)
default_values = self.class.default.map do |key, value|
[

View File

@ -94,22 +94,22 @@ module ActionMailer
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 }
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

View File

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

View File

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