From a50ff956680e4246cfbd377fdbcb1cd992d645c9 Mon Sep 17 00:00:00 2001 From: Tom Freudenberg Date: Thu, 12 Nov 2015 18:00:21 +0100 Subject: [PATCH] New method AttachmentsList.add(attachment) --- lib/mail/attachments_list.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/mail/attachments_list.rb b/lib/mail/attachments_list.rb index a3948ce59..681776824 100644 --- a/lib/mail/attachments_list.rb +++ b/lib/mail/attachments_list.rb @@ -81,6 +81,16 @@ def []=(name, value) @parts_list << attachment end + # Append an already created Mail::Part object to list + # useful when copying attachments from other mails + def add(attachment) + if attachment.kind_of?(Mail::Part) + @parts_list << attachment + else + raise "Only instances of Mail::Part can be directly added to attachments" + end + end + # Uses the mime type to try and guess the encoding, if it is a binary type, or unknown, then we # set it to binary, otherwise as set to plain text def guess_encoding