module Feste::Mailer::ClassMethods

Public Instance Methods

action_methods() click to toggle source
Calls superclass method
# File lib/feste/mailer.rb, line 120
def action_methods
  feste_methods = %w[
    action_categories action_categories= action_categories?
  ]
  Set.new(super - feste_methods)
end
categorize(meths = [], as:) click to toggle source

Assign action(s) to a category @param [Array, Symbol]

The actions in the mailer that are included in the given category can be limited by listing them in an array of symbols.

class ReminderMailer < ActionMailer::Base

  categorize [:send_reminder, :send_update], as: :reminder_emails

  def send_reminder(user)
    ...
  end

  def send_update(user)
    ...
  end

  def send_alert(user)
    ...
  end
end

ReminderMailer.action_categories => {
  send_reminder: :reminder_emails,
  send_update: :reminder_emails
}

If no array is provided, all actions in the mailer will be categorized.

class ReminderMailer < ActionMailer::Base

  categorize as: :reminder_emails

  def send_reminder(user)
    ...
  end

  def send_update(user)
    ...
  end

  def send_alert(user)
    ...
  end
end

ReminderMailer.action_categories => { all: :reminder_emails }
# File lib/feste/mailer.rb, line 115
def categorize(meths = [], as:)
  actions = meths.empty? ? [:all] : meths
  actions.each { |action| self.action_categories[action.to_sym] = as }
end