class ActionMailer::Preview
Attributes
Public Class Methods
Source
# File lib/action_mailer/preview.rb, line 80 def all load_previews if descendants.empty? descendants end
Returns all mailer preview classes.
Source
# File lib/action_mailer/preview.rb, line 88 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.
Source
# File lib/action_mailer/preview.rb, line 101 def email_exists?(email) emails.include?(email) end
Returns true
if the email exists.
Source
# File lib/action_mailer/preview.rb, line 96 def emails public_instance_methods(false).map(&:to_s).sort end
Returns all of the available email previews.
Source
# File lib/action_mailer/preview.rb, line 106 def exists?(preview) all.any? { |p| p.preview_name == preview } end
Returns true
if the preview exists.
Source
# File lib/action_mailer/preview.rb, line 111 def find(preview) all.find { |p| p.preview_name == preview } end
Find a mailer preview by its underscored class name.
Source
# File lib/action_mailer/preview.rb, line 74 def initialize(params = {}) @params = params end
Source
# File lib/action_mailer/preview.rb, line 116 def preview_name name.delete_suffix("Preview").underscore end
Returns the underscored name of the mailer preview without the suffix.
Private Class Methods
Source
# File lib/action_mailer/preview.rb, line 135 def inform_preview_interceptors(message) Base.preview_interceptors.each do |interceptor| interceptor.previewing_email(message) end end
Source
# File lib/action_mailer/preview.rb, line 121 def load_previews if preview_path Dir["#{preview_path}/**/*_preview.rb"].sort.each { |file| require_dependency file } end end
Source
# File lib/action_mailer/preview.rb, line 127 def preview_path Base.preview_path end
Source
# File lib/action_mailer/preview.rb, line 131 def show_previews Base.show_previews end