Sha256: f168c3eb6aa1e9bd5d8225290345e146e8cbb5c5601fd8f04ca3a3c2ef20028b

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

module NotifyUser
  class NotificationMailer < ActionMailer::Base
    helper NotifyUser::ApplicationHelper

    layout "notify_user/layouts/action_mailer"

    def notification_email(notification, options)
      @notification = notification

      mail to: notification.target.email,
           subject: subject(notification, options[:subject]),
           template_name: "notification",
           template_path: "notify_user/action_mailer",
           from: NotifyUser.mailer_sender
    end

    def aggregate_notifications_email(notifications, options)
      @notifications = notifications
      @notification = notifications.first

      mail to: @notifications.first.target.email,
           template_name: "aggregate_notification",
           template_path: ["notify_user/#{notifications.first.class.name.underscore}/action_mailer", "notify_user/action_mailer"],
           subject: subject(@notification, options[:aggregate][:subject]),
           from: NotifyUser.mailer_sender
    end

    def subject(notification, subject)
      subject % notification.params.symbolize_keys
    end

    protected
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
notify_user-0.3.2 app/mailers/notify_user/notification_mailer.rb
notify_user-0.3.1 app/mailers/notify_user/notification_mailer.rb