Sha256: 7b49d9560535644c91873025aa2d1d277f1a07874690a466069e9dd5666666a2

Contents?: true

Size: 779 Bytes

Versions: 1

Compression:

Stored size: 779 Bytes

Contents

module Mail
  class Message
    def tag(val = nil)
      default(:tag, val)
    end

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

    def to_postmark
      {}.tap do |hash|
        %w[bcc cc from html_body reply_to subject tag text_body to].each do |key|
          value = send(key).presence or next
          hash[key.camelcase] = value.respond_to?(:join) ? value.join(', ') : value.to_s
        end
        hash['Attachments'] = attachments.map(&:to_postmark) if has_attachments?
      end
    end
    
    private
    def html_body
      html_part.present? ? html_part.to_postmark['Content'] : content_type && content_type.include?('text/html') ? body : nil
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_postmark-0.1 lib/simple_postmark/mail_ext/message.rb