class Mailtime::Renderers::MailRenderer
Public Class Methods
new(mail)
click to toggle source
# File lib/mailtime/renderers/mail_renderer.rb, line 5 def initialize(mail) @mail = mail end
Public Instance Methods
execute(format)
click to toggle source
# File lib/mailtime/renderers/mail_renderer.rb, line 9 def execute(format) render(format) end
Protected Instance Methods
render(format)
click to toggle source
# File lib/mailtime/renderers/mail_renderer.rb, line 15 def render(format) template = @mail.mailtime_templates.send(format) layout = template.try(:mail_layout) if template.nil? part = @mail.parts.detect { |part| part.content_type.index(Mailtime::Processor::CONTENT_TYPES[format]) } if part.nil? raise TemplateNotFound, "Existing template not found for format #{format}" end return part.body.raw_source else return layout.render(@mail).gsub(Mailtime.configuration.yield_keyword, template.render(@mail)) end end