Class: ActionMailer::Preview
- Inherits:
-
Object
- Object
- ActionMailer::Preview
- Extended by:
- ActiveSupport::DescendantsTracker
- Defined in:
- lib/action_mailer/preview.rb
Class Method Summary collapse
-
.all ⇒ Object
Returns all mailer preview classes.
-
.call(email) ⇒ 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.
Class Method Details
.all ⇒ Object
Returns all mailer preview classes.
56 57 58 59 |
# File 'lib/action_mailer/preview.rb', line 56 def all load_previews if descendants.empty? descendants end |
.call(email) ⇒ 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.
64 65 66 67 68 69 |
# File 'lib/action_mailer/preview.rb', line 64 def call(email) preview = self.new = preview.public_send(email) inform_preview_interceptors() end |
.email_exists?(email) ⇒ Boolean
Returns true if the email exists.
77 78 79 |
# File 'lib/action_mailer/preview.rb', line 77 def email_exists?(email) emails.include?(email) end |
.emails ⇒ Object
Returns all of the available email previews.
72 73 74 |
# File 'lib/action_mailer/preview.rb', line 72 def emails public_instance_methods(false).map(&:to_s).sort end |
.exists?(preview) ⇒ Boolean
Returns true if the preview exists.
82 83 84 |
# File 'lib/action_mailer/preview.rb', line 82 def exists?(preview) all.any?{ |p| p.preview_name == preview } end |
.find(preview) ⇒ Object
Find a mailer preview by its underscored class name.
87 88 89 |
# File 'lib/action_mailer/preview.rb', line 87 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.
92 93 94 |
# File 'lib/action_mailer/preview.rb', line 92 def preview_name name.sub(/Preview$/, '').underscore end |