Skip to content

Commit

Permalink
Access passed tmail object in from_tmail (local var instead of instan…
Browse files Browse the repository at this point in the history
…ce var)
  • Loading branch information
namxam authored and Daniel Parker committed May 5, 2010
1 parent a89ea1f commit e3dc0d8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/mime/entity_tmail.rb
Expand Up @@ -58,16 +58,18 @@ def from_parsed(parsed)
end
raise ArgumentError, "Must pass in either: [an array with two elements: headers(hash) and content(string or array)] OR [a hash containing :type, :boundary, and :content(being the former or a string)]"
end

# Parse a tmail object into our Entity object
def from_tmail(tmail)
raise ArgumentError, "Expecting a TMail::Mail object." unless tmail.is_a?(TMail::Mail)
@headers ||= Hash.new {|h,k| @tmail.header[k].to_s }
@headers ||= Hash.new {|h,k| tmail.header[k].to_s }
if multipart?
@content = @tmail.parts.collect { |tpart| Entity.new.from_tmail(tpart) }
@content = tmail.parts.collect { |tpart| Entity.new.from_tmail(tpart) }
else
set_content @tmail.body # TMail has already decoded it, but we need it still encoded
set_content tmail.body # TMail has already decoded it, but we need it still encoded
end
end

##############
# ATTRIBUTES #

Expand Down

0 comments on commit e3dc0d8

Please sign in to comment.