Module: EffectiveEmailTemplatesMailer
- Extended by:
- ActiveSupport::Concern
- Included in:
- Effective::EmailTemplatesMailer
- Defined in:
- app/mailers/concerns/effective_email_templates_mailer.rb
Overview
Added to effective email templates mailers
Instance Method Summary collapse
Instance Method Details
#mail(headers = {}, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/mailers/concerns/effective_email_templates_mailer.rb', line 6 def mail(headers = {}, &block) email_template = Effective::EmailTemplate.where(template_name: action_name).first! assigns = (@assigns || {}) # Parse assigns. Special keys for body and subject. body = assigns.delete(:body) || headers[:body] || headers['body'] email_template.body = body if body.present? # Ignore the subject when passed in via mail method subject: key. subject = assigns.delete(:subject) email_template.subject = subject if subject.present? # Add any _url helpers assigns = route_url_assigns(email_template).merge(assigns) # Render from the template, possibly with updated body rendered = email_template.render(assigns) super(rendered.merge(headers.except(:body, :subject, 'body', 'subject'))) end |