Class: HrLite::EventMailer

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

Overview

One mailer, two generic responsive templates. Per-event content (heading, body, detail lines, diff table) is assembled by the Notifications bus so adding an event never means adding a template.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

Emails need absolute URLs; the engine can't know its public mount. Hosts set config.public_url_base (e.g. "https://hr.example.com"); unset => emails simply carry no link button.



27
28
29
30
31
# File 'app/mailers/hr_lite/event_mailer.rb', line 27

def self.link_for(path)
  return nil if path.blank?

  HrLite.public_url(path)
end

Instance Method Details

#event(to:, subject:, heading:, body: nil, lines: [], path: nil, link_url: nil) ⇒ Object



6
7
8
9
10
11
12
# File 'app/mailers/hr_lite/event_mailer.rb', line 6

def event(to:, subject:, heading:, body: nil, lines: [], path: nil, link_url: nil)
  @heading = heading
  @body = body
  @lines = Array(lines)
  @cta_url = link_url.presence || HrLite::EventMailer.link_for(path)
  mail(to: to, from: HrLite.config.mailer_from, subject: subject)
end

#leadership(to:, subject:, heading:, body: nil, lines: [], diff: nil, path: nil, event: nil) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'app/mailers/hr_lite/event_mailer.rb', line 14

def leadership(to:, subject:, heading:, body: nil, lines: [], diff: nil, path: nil, event: nil)
  @heading = heading
  @body = body
  @lines = Array(lines)
  @diff = diff.presence
  @event = event
  @cta_url = HrLite::EventMailer.link_for(path)
  mail(to: to, from: HrLite.config.mailer_from, subject: subject)
end