Class: MandrillMailer::TemplateMailer

Inherits:
CoreMailer
  • Object
show all
Defined in:
lib/mandrill_mailer/offline.rb,
lib/mandrill_mailer/template_mailer.rb

Instance Attribute Summary collapse

Attributes inherited from CoreMailer

#async, #ip_pool, #message, #send_at

Instance Method Summary collapse

Methods inherited from CoreMailer

#bcc, default, #from, #mandrill_mail, super_defaults, test, test_setup_for, #to, #to=

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class MandrillMailer::CoreMailer

Instance Attribute Details

#template_contentObject

Public: Template content



117
118
119
# File 'lib/mandrill_mailer/template_mailer.rb', line 117

def template_content
  @template_content
end

#template_nameObject

Public: The name of the template to use



114
115
116
# File 'lib/mandrill_mailer/template_mailer.rb', line 114

def template_name
  @template_name
end

Instance Method Details

#deliverObject

Public: Triggers the stored Mandrill params to be sent to the Mandrill api



120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/mandrill_mailer/template_mailer.rb', line 120

def deliver
  MandrillMailer::Mock.new({
    :template_name    => template_name,
    :template_content => template_content,
    :message          => message,
    :async            => async,
    :ip_pool          => ip_pool,
    :send_at          => send_at
  }).tap do |mock|
     MandrillMailer.deliveries << mock
  end
end

#mandrill_mail_handler(args) ⇒ Object

Handle template mailer specifics before formating the given args



125
126
127
128
129
130
131
132
133
134
# File 'lib/mandrill_mailer/template_mailer.rb', line 125

def mandrill_mail_handler(args)
  # Mandrill requires template content to be there, set default value
  args[:template_content] =  {"blank" => ""} if args[:template_content].blank?

  # Set the template content
  self.template_content = MandrillMailer::ArgFormatter.mandrill_args(args.delete(:template_content))

  # Set the template name
  self.template_name = args.delete(:template)
end