Class: Effective::NotificationsMailer

Inherits:
Object
  • Object
show all
Includes:
EffectiveEmailTemplatesMailer, EffectiveMailer
Defined in:
app/mailers/effective/notifications_mailer.rb

Instance Method Summary collapse

Instance Method Details

#notification(notification, resource = nil, opts = {}) ⇒ Object



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

def notification(notification, resource = nil, opts = {})
  raise('expected an Effective::Notification') unless notification.kind_of?(Effective::Notification)

  @assigns = assigns_for(notification, resource)

  # Find the TO email address for this resource
  to = notification.to_email(resource)
  raise('expected a to email address') unless to.present?

  # Attach report
  attach_report!(notification)
  opts.delete(:content_type) if notification.attach_report?

  # Use postmark broadcast-stream
  if defined?(Postmark)
    opts.merge!(message_stream: 'broadcast-stream')
    append_unsubscribe_link!(notification, opts)
  end

  mail(to: to, **headers_for(resource, opts))
end