Class: SendgridNotification::NotificationMail
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SendgridNotification::NotificationMail
- Defined in:
- app/models/sendgrid_notification/notification_mail.rb
Constant Summary collapse
- VARIABLE_REGEXP_DEFAULT =
/\{\{\s*(\w+)\s*\}\}/
Instance Method Summary collapse
- #apply(params) ⇒ Object
- #sendmail_later(to, params, attachments = []) ⇒ Object (also: #sendmail)
- #sendmail_now(to, params, attachments = []) ⇒ Object
Instance Method Details
#apply(params) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/sendgrid_notification/notification_mail.rb', line 27 def apply(params) unresolved = [] body = content.gsub(variable_regexp) { |_| key = $1 params[key] || params[key.to_sym] || unresolved.push(key) } if unresolved.present? errors.add(:content, :unresolved_template_parameters, variables: unresolved.join(",")) end body end |
#sendmail_later(to, params, attachments = []) ⇒ Object Also known as: sendmail
15 16 17 18 |
# File 'app/models/sendgrid_notification/notification_mail.rb', line 15 def sendmail_later(to, params, = []) = .map(&:to_h) SendmailJob.perform_later(to, self, params, ) end |
#sendmail_now(to, params, attachments = []) ⇒ Object
22 23 24 25 |
# File 'app/models/sendgrid_notification/notification_mail.rb', line 22 def sendmail_now(to, params, = []) = .map(&:to_h) SendmailJob.perform_now(to, self, params, ) end |