Class: Effective::EmailTemplate
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Effective::EmailTemplate
- Includes:
- ActionView::Helpers::TextHelper
- Defined in:
- app/models/effective/email_template.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
Returns the value of attribute current_user.
Instance Method Summary collapse
- #body_plain? ⇒ Boolean
- #content_type ⇒ Object
- #render(assigns = {}) ⇒ Object
- #template_variables ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
7 8 9 |
# File 'app/models/effective/email_template.rb', line 7 def current_user @current_user end |
Instance Method Details
#body_plain? ⇒ Boolean
58 59 60 |
# File 'app/models/effective/email_template.rb', line 58 def body_plain? body.present? && !(body.include?('</p>') || body.include?('</div>')) end |
#content_type ⇒ Object
54 55 56 |
# File 'app/models/effective/email_template.rb', line 54 def content_type 'text/html' end |
#render(assigns = {}) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/effective/email_template.rb', line 62 def render(assigns = {}) assigns = deep_stringify_assigns(assigns) { from: from, cc: cc.presence, bcc: bcc.presence, subject: template_subject.render(assigns), body: template_body.render(assigns) }.compact end |
#template_variables ⇒ Object
74 75 76 77 78 79 80 |
# File 'app/models/effective/email_template.rb', line 74 def template_variables [template_body.presence, template_subject.presence].compact.map do |template| Liquid::ParseTreeVisitor.for(template.root).add_callback_for(Liquid::VariableLookup) do |node| [node.name, *node.lookups].join('.') end.visit end.flatten.uniq.compact end |
#to_s ⇒ Object
50 51 52 |
# File 'app/models/effective/email_template.rb', line 50 def to_s template_name.presence || 'New Email Template' end |