Sha256: f2d6832cf1f5312904519f50a11a1708ba7bc5203ea9ab14cb39bccf6a09b625

Contents?: true

Size: 710 Bytes

Versions: 1

Compression:

Stored size: 710 Bytes

Contents

module ActionMailer
  module Textgiri
    def self.included(klass)
      klass.class_eval do
        include ActionMailer::Textgiri::HtmlToPlainText
      end
    end

    def collect_responses(headers)
      responses = super headers
      html_part = responses.detect { |response| response[:content_type] == 'text/html' }
      text_part = responses.detect { |response| response[:content_type] == 'text/plain' }
      if html_part && !text_part
        responses.insert 0, content_type: 'text/plain', body: convert_to_text(html_part[:body])
        headers[:parts_order] = ['text/plain'] + headers[:parts_order] unless headers[:parts_order].include?('text/plain')
      end
      responses
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
actionmailer-textgiri-0.2.1 lib/actionmailer-textgiri/text.rb