class Mailtime::Processor
Constants
- CONTENT_TYPES
Public Class Methods
new(mail)
click to toggle source
# File lib/mailtime/processor/processor.rb, line 15 def initialize(mail) @mail = mail end
Public Instance Methods
execute()
click to toggle source
# File lib/mailtime/processor/processor.rb, line 19 def execute process_mail end
Protected Instance Methods
process_mail()
click to toggle source
# File lib/mailtime/processor/processor.rb, line 25 def process_mail remove_parts render_mail log_mail @mail end
Private Instance Methods
apply_part(renderer, format)
click to toggle source
# File lib/mailtime/processor/processor.rb, line 68 def apply_part(renderer, format) remove_part(format) if mail_has_template?(format) part = Mail::Part.new do content_type "#{CONTENT_TYPES[format]}; charset=UTF-8" body renderer.execute(format) end mthd = "#{format}_part=".to_sym @mail.send(mthd, part) end
apply_parts(renderer)
click to toggle source
# File lib/mailtime/processor/processor.rb, line 62 def apply_parts(renderer) [:text, :html].each do |format| apply_part(renderer, format) end end
log_for_recipients()
click to toggle source
# File lib/mailtime/processor/processor.rb, line 55 def log_for_recipients Mailtime.configuration.loggables.each do |loggable, options| svc = MailLogService.new(@mail, loggable, options) svc.log end end
log_mail()
click to toggle source
# File lib/mailtime/processor/processor.rb, line 50 def log_mail return unless Mailtime.configuration.log log_for_recipients end
mail_has_template?(format)
click to toggle source
# File lib/mailtime/processor/processor.rb, line 78 def mail_has_template?(format) !!!@mail.mailtime_templates.send(format).nil? end
remove_part(format)
click to toggle source
# File lib/mailtime/processor/processor.rb, line 34 def remove_part(format) index = @mail.parts.index { |mail_part| mail_part.content_type.index(Mailtime::Processor::CONTENT_TYPES[format])} @mail.parts.delete_at(index) end
remove_parts()
click to toggle source
# File lib/mailtime/processor/processor.rb, line 39 def remove_parts end
render_mail()
click to toggle source
# File lib/mailtime/processor/processor.rb, line 43 def render_mail return @mail unless Mailtime.configuration.render renderer = Mailtime::Renderers::MailRenderer.new(@mail) apply_parts(renderer) @mail end