Sha256: 392d45b038e3973ec41c29003a8a4766516873f0a19de29e08a0d712cc85c0b5

Contents?: true

Size: 786 Bytes

Versions: 5

Compression:

Stored size: 786 Bytes

Contents

module Mail
  class Message
    def html_body
      if html_part.present?
        html_part.to_postmark['Content']
      else
        body if content_type.to_s.include?('text/html')
      end
    end

    def tag(val = nil)
      default(:tag, val)
    end

    def tag=(val)
      header[:tag] = val
    end

    def text_body
      text_part.present? ? text_part.to_postmark['Content'] : body
    end

    def to_postmark
      %w[attachments bcc cc from html_body reply_to subject tag text_body to].each.with_object({}) do |key, hash|
        hash[key.camelcase] = case (value = public_send(key).presence or next)
          when AttachmentsList then value.map(&:to_postmark)
          when Array then value.join(', ')
          else value.to_s
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple_postmark-0.4.3 lib/simple_postmark/mail_ext/message.rb
simple_postmark-0.4.2 lib/simple_postmark/mail_ext/message.rb
simple_postmark-0.4.1 lib/simple_postmark/mail_ext/message.rb
simple_postmark-0.4.0 lib/simple_postmark/mail_ext/message.rb
simple_postmark-0.3.5 lib/simple_postmark/mail_ext/message.rb