Class: ApplicationMailer

Inherits:
ActionMailer::Base
  • Object
show all
Includes:
ElasticApmContext, Workers::Helpers
Defined in:
app/mailers/application_mailer.rb

Overview

typed: ignore

Instance Method Summary collapse

Methods included from Workers::Helpers

#parse_json

Instance Method Details

#log_mailer(data) ⇒ Object

Parameters:

  • data (Hash)

    :subject [String] :reservation_id [Integer] :user_id [Integer] :restaurant_id [Integer] :other [Hash]



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/mailers/application_mailer.rb', line 18

def log_mailer(data)
  if data[:reservation_id] || data[:user_id] || data[:restaurant_id]
    BUSINESS_LOGGER.set_business_context({
                                           reservation_id: data[:reservation_id],
                                           user_id: data[:user_id],
                                           restaurant_id: data[:restaurant_id],
                                         })
  end

  message = data[:subject]
  payload = data.except(:subject)
  if message.blank? || payload.blank?
    raise ArgumentError, 'subject and payload are required'
  end

  BUSINESS_LOGGER.info(message, payload)
rescue StandardError => e
  APMErrorHandler.report e, data
  true
end

#switch_locale(&action) ⇒ Object



6
7
8
9
10
# File 'app/mailers/application_mailer.rb', line 6

def switch_locale(&action)
  I18n.with_locale(:en) do
    Globalize.with_locale(:en, &action)
  end
end