Use each_with_object and make the code pithier

This commit is contained in:
Herve Saint-Amand 2017-01-28 23:27:04 +00:00
parent a371aad9ac
commit 74e28f8bd0

View file

@ -187,15 +187,13 @@ module ActiveSupport
end end
def email_text_parts(message) def email_text_parts(message)
text_parts = [] message.parts.each_with_object([]) do |part, text_parts|
message.parts.each do |part|
if part.content_type.start_with?("text/") if part.content_type.start_with?("text/")
text_parts.push(part) text_parts.push(part)
elsif part.multipart? elsif part.multipart?
text_parts.concat(email_text_parts(part)) text_parts.concat(email_text_parts(part))
end end
end end
text_parts
end end
end end
end end