Class: NotificationMailer

Inherits:
ApplicationMailer show all
Defined in:
app/mailers/notification_mailer.rb

Instance Method Summary collapse

Instance Method Details

#notification(recipient:, event_notification_configuration:, reference_event:) ⇒ Object



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

def notification(
  recipient:,
  event_notification_configuration:,
  reference_event:
)
  params_class = event_notification_configuration.sender_params_class

  @params = params_class.new(
    event_notification_configuration: event_notification_configuration,
    reference_event: reference_event,
    recipient: recipient
  )

  I18n.with_locale(recipient.locale) do
    mail(
      to: @params.to,
      subject: @params.subject,
      from: @params.from,
      template_name: @params.template_name
    )
  end
end