Sha256: 409df6fad69eb8f2bd510a9087411b4da718def42b7be40e2cad882179399785

Contents?: true

Size: 783 Bytes

Versions: 1

Compression:

Stored size: 783 Bytes

Contents

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

    def tag=(val)
      header[:tag] = val
    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 = send(key).presence or next)
          when AttachmentsList then value.map(&:to_postmark)
          when Array then value.join(', ')
          else value.to_s
        end
      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.2 lib/simple_postmark/mail_ext/message.rb