class ActionMailer::Preview
Attributes
params[R]
Public Class Methods
all()
click to toggle source
Returns all mailer preview classes.
# File lib/action_mailer/preview.rb, line 79 def all load_previews if descendants.empty? descendants end
call(email, params = {})
click to toggle 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 lib/action_mailer/preview.rb, line 87 def call(email, params = {}) preview = new(params) message = preview.public_send(email) inform_preview_interceptors(message) message end
email_exists?(email)
click to toggle source
Returns true
if the email exists.
# File lib/action_mailer/preview.rb, line 100 def email_exists?(email) emails.include?(email) end
emails()
click to toggle source
Returns all of the available email previews.
# File lib/action_mailer/preview.rb, line 95 def emails public_instance_methods(false).map(&:to_s).sort end
exists?(preview)
click to toggle source
Returns true
if the preview exists.
# File lib/action_mailer/preview.rb, line 105 def exists?(preview) all.any? { |p| p.preview_name == preview } end
find(preview)
click to toggle source
Find a mailer preview by its underscored class name.
# File lib/action_mailer/preview.rb, line 110 def find(preview) all.find { |p| p.preview_name == preview } end
new(params = {})
click to toggle source
# File lib/action_mailer/preview.rb, line 73 def initialize(params = {}) @params = params end
preview_name()
click to toggle source
Returns the underscored name of the mailer preview without the suffix.
# File lib/action_mailer/preview.rb, line 115 def preview_name name.sub(/Preview$/, "").underscore end
Private Class Methods
inform_preview_interceptors(message)
click to toggle source
# File lib/action_mailer/preview.rb, line 134 def inform_preview_interceptors(message) Base.preview_interceptors.each do |interceptor| interceptor.previewing_email(message) end end
load_previews()
click to toggle source
# File lib/action_mailer/preview.rb, line 120 def load_previews if preview_path Dir["#{preview_path}/**/*_preview.rb"].sort.each { |file| require_dependency file } end end
preview_path()
click to toggle source
# File lib/action_mailer/preview.rb, line 126 def preview_path Base.preview_path end
show_previews()
click to toggle source
# File lib/action_mailer/preview.rb, line 130 def show_previews Base.show_previews end