W3cubDocs

/Ruby on Rails 5.1

class ActionMailer::Preview

Parent:
Object

Public Class Methods

all() Show source

Returns all mailer preview classes.

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

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.

# File actionmailer/lib/action_mailer/preview.rb, line 65
def call(email)
  preview = new
  message = preview.public_send(email)
  inform_preview_interceptors(message)
  message
end
email_exists?(email) Show source

Returns true if the email exists.

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

Returns all of the available email previews.

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

Returns true if the preview exists.

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

Find a mailer preview by its underscored class name.

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

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

# File actionmailer/lib/action_mailer/preview.rb, line 93
def preview_name
  name.sub(/Preview$/, "").underscore
end

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