Class: Mail::Message
- Inherits:
-
Object
- Object
- Mail::Message
- Defined in:
- lib/simple_postmark/mail_ext/message.rb
Instance Method Summary collapse
- #html_body ⇒ Object
- #tag(val = nil) ⇒ Object
- #tag=(val) ⇒ Object
- #text_body ⇒ Object
- #to_postmark ⇒ Object
Instance Method Details
#html_body ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/simple_postmark/mail_ext/message.rb', line 3 def html_body if html_part.present? html_part.to_postmark['Content'] else body if content_type.to_s.include?('text/html') end end |
#tag(val = nil) ⇒ Object
11 12 13 |
# File 'lib/simple_postmark/mail_ext/message.rb', line 11 def tag(val = nil) default(:tag, val) end |
#tag=(val) ⇒ Object
15 16 17 |
# File 'lib/simple_postmark/mail_ext/message.rb', line 15 def tag=(val) header[:tag] = val end |
#text_body ⇒ Object
19 20 21 |
# File 'lib/simple_postmark/mail_ext/message.rb', line 19 def text_body text_part.present? ? text_part.to_postmark['Content'] : body end |
#to_postmark ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/simple_postmark/mail_ext/message.rb', line 23 def to_postmark %w[attachments bcc cc from html_body reply_to subject tag text_body to].each.with_object({}) do |key, hash| # mail returns different responses for mail[:reply_to] than mail.reply_to, and we want to prefer the former # as it includes the name, not just the email key_value = self[key.to_sym].nil? ? public_send(key) : self[key.to_sym] hash[key.camelcase] = case (value = key_value.presence or next) when AttachmentsList then value.map(&:to_postmark) when Array then value.join(', ') else value.to_s end end end |