Module: PostmarkRails::TemplatedMailerMixin

Included in:
TemplatedMailer
Defined in:
lib/postmark-rails/templated_mailer.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

READ_ONLY_HEADERS =
%w(body content_type subject).freeze
BODY_STUB =
'Temporary Postmark Template Body'.freeze
SUBJECT_STUB =
'Temporary Postmark Template Subject'.freeze
ALIAS_STUB =
proc { action_name }

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mailer) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/postmark-rails/templated_mailer.rb', line 10

def self.included(mailer)
  mailer.default(
    :body => BODY_STUB,
    :content_type => 'text/plain',
    :subject => SUBJECT_STUB,
    :postmark_template_alias => ALIAS_STUB
  )
  mailer.extend(ClassMethods)
end

Instance Method Details

#mail(headers = {}) ⇒ Object



28
29
30
31
32
33
# File 'lib/postmark-rails/templated_mailer.rb', line 28

def mail(headers = {})
  super(self.class.safe_headers(headers))
ensure
  message.body = standard_template_body
  message.subject = standard_template_subject
end

#template_model(*args) ⇒ Object



20
21
22
# File 'lib/postmark-rails/templated_mailer.rb', line 20

def template_model(*args)
  message.template_model(*args)
end

#template_model=(model) ⇒ Object



24
25
26
# File 'lib/postmark-rails/templated_mailer.rb', line 24

def template_model=(model)
  message.template_model = model
end