module Eventifier::Mailers::Helpers

Protected Instance Methods

eventifier_mail(user, records, action) click to toggle source

Configure default email options

# File lib/eventifier/mailers/helpers.rb, line 13
def eventifier_mail(user, records, action)
  initialize_from_record(user, records)
  mail headers_for(action)
end
headers_for(action) click to toggle source
# File lib/eventifier/mailers/helpers.rb, line 22
def headers_for(action)
  headers = {
    :subject       => I18n.t(:email_subject, :scope => [:notifications]),
    :from          => mailer_sender,
    :to            => @user.email,
    :template_path => template_paths
  }

  headers[:reply_to] = headers[:from] unless headers.key?(:reply_to)

  headers
end
initialize_from_record(user, records) click to toggle source
# File lib/eventifier/mailers/helpers.rb, line 18
def initialize_from_record(user, records)
  @user, @notifications = user, records
end
mailer_sender() click to toggle source
# File lib/eventifier/mailers/helpers.rb, line 35
def mailer_sender
  if default_params[:from].present?
    default_params[:from]
  else
    Eventifier.mailer_sender
  end
end
template_paths() click to toggle source
# File lib/eventifier/mailers/helpers.rb, line 43
def template_paths
  self.class.mailer_name
end
translate(mapping, key) click to toggle source

Setup a subject doing an I18n lookup. At first, it attemps to set a subject based on the current mapping:

en:
  devise:
    mailer:
      confirmation_instructions:
        user_subject: '...'

If one does not exist, it fallbacks to ActionMailer default:

en:
  devise:
    mailer:
      confirmation_instructions:
        subject: '...'
# File lib/eventifier/mailers/helpers.rb, line 64
def translate(mapping, key)
  I18n.t(:"notifications_subject", :scope => [:eventifier, :notifications, key],
    :default => [:subject, key.to_s.humanize])
end