Sha256: 7715eead5f4f902f0f844201ca38ad93787679ead85b83c68755e95e5e641db6

Contents?: true

Size: 798 Bytes

Versions: 1

Compression:

Stored size: 798 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
      hash = {}
      
      %w[attachments bcc cc from html_body reply_to subject tag text_body to].each do |key|
        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
      
      hash
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_postmark18-0.4.0 lib/simple_postmark/mail_ext/message.rb