Class: Wupee::NotificationsMailer

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
app/mailers/wupee/notifications_mailer.rb

Direct Known Subclasses

NotificationsMailer

Instance Method Summary collapse

Instance Method Details

#send_mail_for(notification, subject_interpolations = {}, locals_interpolations = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/mailers/wupee/notifications_mailer.rb', line 5

def send_mail_for(notification, subject_interpolations = {}, locals_interpolations = {})
  @notification = notification
  @receiver = notification.receiver
  @attached_object = notification.attached_object
  @subject_interpolations = subject_interpolations
  @locals = locals_interpolations

  if !respond_to?(notification.notification_type.name)
    class_eval %Q{
      def #{notification.notification_type.name}
        mail to: @receiver.email,
             subject: t('wupee.email_subjects.#{notification.notification_type.name}', @subject_interpolations),
             template_name: '#{notification.notification_type.name}',
             content_type: 'text/html'
      end
    }
  end

  send(notification.notification_type.name)
end