Class: NotifyWith::NotificationsMailer

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

Direct Known Subclasses

NotificationsMailer

Instance Method Summary collapse

Instance Method Details

#send_mail_by(notification) ⇒ Object



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

def send_mail_by(notification)
  @notification = notification
  @recipient = notification.receiver
  @attached_object = notification.attached_object

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

  send(notification.notification_type)
end