Class: TransactionalEmailMailer

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

Instance Method Summary collapse

Instance Method Details

#build(email, google_analytics_client_id, opt = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/mailers/transactional_email_mailer.rb', line 4

def build(email, google_analytics_client_id, opt = {})
  @google_analytics_client_id = google_analytics_client_id
  @google_analytics_tracking_id = Settings.google_analytics.tracking_id

  mail(
    opt.merge(
      to: email,
      subject: self.class::SUBJECT,
      content_type: 'text/html',
      body: template
    )
  )
end

#first_and_last_name(name) ⇒ Object



24
25
26
27
28
# File 'app/mailers/transactional_email_mailer.rb', line 24

def first_and_last_name(name)
  return '' if name.nil?

  "#{name.first} #{name.last}"
end

#first_initial_last_name(name) ⇒ Object



18
19
20
21
22
# File 'app/mailers/transactional_email_mailer.rb', line 18

def first_initial_last_name(name)
  return '' if name.nil?

  "#{name.first[0, 1]} #{name.last}"
end

#template(name = self.class::TEMPLATE) ⇒ Object



30
31
32
33
# File 'app/mailers/transactional_email_mailer.rb', line 30

def template(name = self.class::TEMPLATE)
  template_file = File.read("app/mailers/views/#{name}.html.erb")
  ERB.new(template_file).result(binding)
end