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 = {}) ⇒ Object (also: #sendmail)
- #sendmail_now(to, params = {}) ⇒ Object
Instance Method Details
#apply(params) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/sendgrid_notification/notification_mail.rb', line 26 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 = {}) ⇒ Object Also known as: sendmail
16 17 18 |
# File 'app/models/sendgrid_notification/notification_mail.rb', line 16 def sendmail_later(to, params = {}) SendmailJob.perform_later(to, self, params) end |
#sendmail_now(to, params = {}) ⇒ Object
22 23 24 |
# File 'app/models/sendgrid_notification/notification_mail.rb', line 22 def sendmail_now(to, params = {}) SendmailJob.perform_now(to, self, params) end |