Class: Forcast::Utils::Email::Layout

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
lib/forcast/utils/email.rb

Instance Method Summary collapse

Instance Method Details

#default(object:, rule:, obj_identifier:) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/forcast/utils/email.rb', line 29

def default(object:, rule:, obj_identifier:)
  @obj_identifier = obj_identifier
  @attr_watched = { name: rule.attr_comparable, value: object.send(rule.attr_comparable) }
  @fecha = ActiveSupport::TimeZone.new('America/Santiago')
                                  .utc_to_local(Time.now)
                                  .strftime('Hora: %H:%M:%S - Fecha: %d/%m/%Y')
  @obj_class = rule.rule_model

  subject = "Gatillada regla #{rule.name} - #{rule.rule_model} #{obj_identifier}"

  mail(to: params[:to], cc: params[:cc], subject: subject,
       from: ActionMailer::Base.smtp_settings[:user_name]) do |format|
    format.text(content_type: 'text/plain', charset: 'UTF-8',
                content_transfer_encoding: '7bit')
  end
  # Guardar response en ActionLogs junto con los datos pertinentes. Tabla
end