Class: DevelopmentNotification::Email
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- DevelopmentNotification::Email
- Defined in:
- app/models/development_notification/email.rb
Class Method Summary collapse
- .create_from_leadersend_response_hash(**hash) ⇒ Object
- .send_email(title: nil, to: nil, from: nil, fromname: nil, subject: nil, template: nil, template_path: nil, locals: nil) ⇒ Object
-
.statuses ⇒ Object
private.
Class Method Details
.create_from_leadersend_response_hash(**hash) ⇒ Object
30 31 32 33 34 35 |
# File 'app/models/development_notification/email.rb', line 30 def self.create_from_leadersend_response_hash(**hash) hash[:status] = self.statuses[hash[:status]] sent_mail = self.new(hash.symbolize_keys, :without_protection => true) sent_mail.save return sent_mail end |
.send_email(title: nil, to: nil, from: nil, fromname: nil, subject: nil, template: nil, template_path: nil, locals: nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/development_notification/email.rb', line 12 def self.send_email(title: nil, to: nil, from: nil, fromname: nil, subject: nil, template: nil, template_path: nil, locals: nil) mailer = Leadersend::Mail.new(title: title, to: to, from: from, fromname: fromname, subject: subject, template: template) leadersend_response_hash = mailer.send mail_object = DevelopmentNotification::Email.create_from_leadersend_response_hash(leadersend_response_hash) return mail_object # TODO add differentiation based on template/template_path argument to use raw html or path accordingly. end |
.statuses ⇒ Object
private
26 27 28 |
# File 'app/models/development_notification/email.rb', line 26 def self.statuses ActiveSupport::HashWithIndifferentAccess.new(new: 0, sent: 1, error: 2) end |