class ActionMailer::Preview

Parent:
Object

Attributes

params[R]

Public Class Methods

all() Show source
# File actionmailer/lib/action_mailer/preview.rb, line 81
def all
  load_previews if descendants.empty?
  descendants
end

Returns all mailer preview classes.

call(email, params = {}) Show source
# File actionmailer/lib/action_mailer/preview.rb, line 89
def call(email, params = {})
  preview = new(params)
  message = preview.public_send(email)
  inform_preview_interceptors(message)
  message
end

Returns the mail object for the given email name. The registered preview interceptors will be informed so that they can transform the message as they would if the mail was actually being delivered.

email_exists?(email) Show source
# File actionmailer/lib/action_mailer/preview.rb, line 102
def email_exists?(email)
  emails.include?(email)
end

Returns true if the email exists.

emails() Show source
# File actionmailer/lib/action_mailer/preview.rb, line 97
def emails
  public_instance_methods(false).map(&:to_s).sort
end

Returns all of the available email previews.

exists?(preview) Show source
# File actionmailer/lib/action_mailer/preview.rb, line 107
def exists?(preview)
  all.any? { |p| p.preview_name == preview }
end

Returns true if the preview exists.

find(preview) Show source
# File actionmailer/lib/action_mailer/preview.rb, line 112
def find(preview)
  all.find { |p| p.preview_name == preview }
end

Find a mailer preview by its underscored class name.

new(params = {}) Show source
# File actionmailer/lib/action_mailer/preview.rb, line 75
def initialize(params = {})
  @params = params
end
preview_name() Show source
# File actionmailer/lib/action_mailer/preview.rb, line 117
def preview_name
  name.sub(/Preview$/, "").underscore
end

Returns the underscored name of the mailer preview without the suffix.

© 2004–2019 David Heinemeier Hansson
Licensed under the MIT License.