Class: Heya::CampaignMailer

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

Instance Method Summary collapse

Instance Method Details

#buildObject



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

def build
  user = params.fetch(:user)
  step = params.fetch(:step)
  campaign = step.campaign
  from = step.params.fetch("from")
  reply_to = step.params.fetch("reply_to", nil)
  subject = step.params.fetch("subject")

  instance_variable_set(:"@#{user.model_name.element}", user)

  mail(
    from: from,
    reply_to: reply_to,
    to: user.email,
    subject: subject,
    template_path: "heya/campaign_mailer/#{campaign.name.underscore}",
    template_name: step.name.underscore
  )
end