跳至内容 跳至搜索
方法
A
C
E
F
N
P

属性

[R] params

类公共方法

all()

返回所有邮件预览类。

# File actionmailer/lib/action_mailer/preview.rb, line 80
def all
  load_previews if descendants.empty?
  descendants.sort_by { |mailer| mailer.name.titleize }
end

call(email, params = {})

返回给定邮件名称的邮件对象。已注册的预览拦截器将被通知,以便它们可以像实际发送邮件一样转换邮件。

# File actionmailer/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

email_exists?(email)

如果邮件存在,则返回true

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

emails()

返回所有可用的邮件预览。

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

exists?(preview)

如果预览存在,则返回true

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

find(preview)

通过其下划线类名查找邮件预览。

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

new(params = {})

# File actionmailer/lib/action_mailer/preview.rb, line 74
def initialize(params = {})
  @params = params
end

preview_name()

返回邮件预览的下划线名称,不带后缀。

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