module Mail::Notify::MailersController

Public Instance Methods

preview() click to toggle source
Calls superclass method
# File lib/mail/notify/mailers_controller.rb, line 6
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 Instance Methods

notify?() click to toggle source
# File lib/mail/notify/mailers_controller.rb, line 35
def notify?
  @email.delivery_method.class == Mail::Notify::DeliveryMethod
end
render_part() click to toggle source
# File lib/mail/notify/mailers_controller.rb, line 21
def render_part
  # Add the current directory to the view path so that Rails can find
  # the `govuk_notify_layout` layout
  append_view_path(__dir__)

  response.content_type = "text/html"
  render html: @email.preview.html.html_safe, layout: "govuk_notify_layout"
end
render_preview_wrapper() click to toggle source
# File lib/mail/notify/mailers_controller.rb, line 30
def render_preview_wrapper
  @part = @email
  render action: "email", layout: false, formats: %i[html]
end