Sha256: e0512266d48c67d875809499baec76b7c6b0978e135b2a65809f13dfdc6f309f

Contents?: true

Size: 763 Bytes

Versions: 5

Compression:

Stored size: 763 Bytes

Contents

# frozen_string_literal: true

module Roadie
  module Rails
    class MailInliner
      attr_reader :email, :options

      def initialize(email, options)
        @email = email
        @options = options
      end

      def execute
        if options
          improve_body if %r{^text/html}.match?(email.content_type)
          improve_html_part(email.html_part) if email.html_part
        end
        email
      end

      private

      def improve_body
        email.body = transform_html(email.body.decoded)
      end

      def improve_html_part(html_part)
        html_part.body = transform_html(html_part.body.decoded)
      end

      def transform_html(old_html)
        DocumentBuilder.build(old_html, options).transform
      end
    end
  end
end

Version data entries

5 entries across 4 versions & 2 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/roadie-rails-3.3.0/lib/roadie/rails/mail_inliner.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/roadie-rails-3.3.0/lib/roadie/rails/mail_inliner.rb
roadie-rails-3.3.0 lib/roadie/rails/mail_inliner.rb
roadie-rails-3.1.0 lib/roadie/rails/mail_inliner.rb
roadie-rails-3.0.0 lib/roadie/rails/mail_inliner.rb