Skip to content

Commit

Permalink
Adding #read to return decoded attachment body
Browse files Browse the repository at this point in the history
  • Loading branch information
mikel committed Jan 21, 2010
1 parent ec3a0e0 commit 63af451
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/mail/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,14 @@ def decoded
end
end

def read
if self.attachment?
decode_body
else
raise NoMethodError, 'Can not call read on a part unless it is an attachment.'
end
end

def decode_body
if Mail::Encodings.defined?(content_transfer_encoding)
Mail::Encodings.get_encoding(content_transfer_encoding).decode(body.encoded)
Expand Down

0 comments on commit 63af451

Please sign in to comment.