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
def email_text_parts(message)
text_parts = []
message.parts.each do |part|
message.parts.each_with_object([]) do |part, text_parts|
if part.content_type.start_with?("text/")
text_parts.push(part)
elsif part.multipart?
text_parts.concat(email_text_parts(part))
end
end
text_parts
end
end
end