Class: ActionMailer::Preview
- Extended by:
- ActiveSupport::DescendantsTracker
- Defined in:
- actionmailer/lib/action_mailer/preview.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
-
.all ⇒ Object
Returns all mailer preview classes.
-
.call(email, params = {}) ⇒ Object
Returns the mail object for the given email name.
-
.email_exists?(email) ⇒ Boolean
Returns
true
if the email exists. -
.emails ⇒ Object
Returns all of the available email previews.
-
.exists?(preview) ⇒ Boolean
Returns
true
if the preview exists. -
.find(preview) ⇒ Object
Find a mailer preview by its underscored class name.
-
.preview_name ⇒ Object
Returns the underscored name of the mailer preview without the suffix.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Preview
constructor
A new instance of Preview.
Methods included from ActiveSupport::DescendantsTracker
clear, descendants, descendants, direct_descendants, direct_descendants, inherited, store_inherited
Constructor Details
#initialize(params = {}) ⇒ Preview
Returns a new instance of Preview.
74 75 76 |
# File 'actionmailer/lib/action_mailer/preview.rb', line 74 def initialize(params = {}) @params = params end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params
72 73 74 |
# File 'actionmailer/lib/action_mailer/preview.rb', line 72 def params @params end |
Class Method Details
.all ⇒ Object
Returns all mailer preview classes.
80 81 82 83 |
# File 'actionmailer/lib/action_mailer/preview.rb', line 80 def all load_previews if descendants.empty? descendants end |
.call(email, params = {}) ⇒ Object
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.
88 89 90 91 92 93 |
# File 'actionmailer/lib/action_mailer/preview.rb', line 88 def call(email, params = {}) preview = new(params) = preview.public_send(email) inform_preview_interceptors() end |
.email_exists?(email) ⇒ Boolean
Returns true
if the email exists.
101 102 103 |
# File 'actionmailer/lib/action_mailer/preview.rb', line 101 def email_exists?(email) emails.include?(email) end |
.emails ⇒ Object
Returns all of the available email previews.
96 97 98 |
# File 'actionmailer/lib/action_mailer/preview.rb', line 96 def emails public_instance_methods(false).map(&:to_s).sort end |
.exists?(preview) ⇒ Boolean
Returns true
if the preview exists.
106 107 108 |
# File 'actionmailer/lib/action_mailer/preview.rb', line 106 def exists?(preview) all.any? { |p| p.preview_name == preview } end |
.find(preview) ⇒ Object
Find a mailer preview by its underscored class name.
111 112 113 |
# File 'actionmailer/lib/action_mailer/preview.rb', line 111 def find(preview) all.find { |p| p.preview_name == preview } end |
.preview_name ⇒ Object
Returns the underscored name of the mailer preview without the suffix.
116 117 118 |
# File 'actionmailer/lib/action_mailer/preview.rb', line 116 def preview_name name.sub(/Preview$/, "").underscore end |