Methods

Attributes

[R] params

Class Public methods

all()

Returns all mailer preview classes.

📝 Source code
# File actionmailer/lib/action_mailer/preview.rb, line 64
      def all
        load_previews if descendants.empty?
        descendants
      end
🔎 See on GitHub

call(email, params = {})

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 code
# File actionmailer/lib/action_mailer/preview.rb, line 72
      def call(email, params = {})
        preview = new(params)
        message = preview.public_send(email)
        inform_preview_interceptors(message)
        message
      end
🔎 See on GitHub

email_exists?(email)

Returns true if the email exists.

📝 Source code
# File actionmailer/lib/action_mailer/preview.rb, line 85
      def email_exists?(email)
        emails.include?(email)
      end
🔎 See on GitHub

emails()

Returns all of the available email previews.

📝 Source code
# File actionmailer/lib/action_mailer/preview.rb, line 80
      def emails
        public_instance_methods(false).map(&:to_s).sort
      end
🔎 See on GitHub

exists?(preview)

Returns true if the preview exists.

📝 Source code
# File actionmailer/lib/action_mailer/preview.rb, line 90
      def exists?(preview)
        all.any? { |p| p.preview_name == preview }
      end
🔎 See on GitHub

find(preview)

Find a mailer preview by its underscored class name.

📝 Source code
# File actionmailer/lib/action_mailer/preview.rb, line 95
      def find(preview)
        all.find { |p| p.preview_name == preview }
      end
🔎 See on GitHub

new(params = {})

📝 Source code
# File actionmailer/lib/action_mailer/preview.rb, line 58
    def initialize(params = {})
      @params = params
    end
🔎 See on GitHub

preview_name()

Returns the underscored name of the mailer preview without the suffix.

📝 Source code
# File actionmailer/lib/action_mailer/preview.rb, line 100
      def preview_name
        name.sub(/Preview$/, "").underscore
      end
🔎 See on GitHub