Sha256: 9ccac4d7a603121c16a1e671b7642a12b974388ff80956cd393abd4df2a2685c

Contents?: true

Size: 796 Bytes

Versions: 2

Compression:

Stored size: 796 Bytes

Contents

# frozen_string_literal: true

module Mail
  module Notify
    module MailersController
      def preview
        @email_action = File.basename(params[:path])
        return super unless @preview.email_exists?(@email_action)

        @email = @preview.call(@email_action, params)

        return super unless notify?

        return render_part if params[:part]

        render_preview_wrapper
      end

      private

      def render_part
        response.content_type = 'text/html'
        render plain: @email.preview.html.html_safe
      end

      def render_preview_wrapper
        @part = @email
        render action: 'email', layout: false, formats: %w[html]
      end

      def notify?
        @email.delivery_method.class == Mail::Notify::DeliveryMethod
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mail-notify-0.2.0 lib/mail/notify/mailers_controller.rb
mail-notify-0.1.0 lib/mail/notify/mailers_controller.rb