Sha256: de33c93b72c246c0e6d8b7dc1076f03e9ba96990248623ee8175c5ced82fddf6
Contents?: true
Size: 833 Bytes
Versions: 10
Compression:
Stored size: 833 Bytes
Contents
module Effective class EmailTemplatesMailer < ::ActionMailer::Base def mail(headers = {}, &block) email_template = Effective::EmailTemplate.where(template_name: action_name).first! # Parse Assigns. :body is a special key assigns = (@assigns || {}) if (body = assigns.delete(:body)) email_template.body = body end 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)) end private def route_url_assigns(email_template) email_template.template_variables.select { |name| name.ends_with?('_url') }.inject({}) do |h, name| h[name] = public_send(name) if respond_to?(name); h end end end end
Version data entries
10 entries across 10 versions & 1 rubygems