effective_email_templates 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70659c858db00ba3550202875f36f68c3fdc8f955cc0ec6c9c804d82cc45f809
4
- data.tar.gz: bcbc544fa37ab446f1a8bc2ddaa88e6aceb96596018bb1b4fa30ade686fdbd7f
3
+ metadata.gz: b61c8d36a7412e96eef80c03fb75480a8da1de2156b67587d7fb88b24e85e7bd
4
+ data.tar.gz: dca4e0ccafebf84a7b19f78797854fbb98d1547e18d7a593b408f69ef6e3658c
5
5
  SHA512:
6
- metadata.gz: c1f5c5322dfd9717ccd295e175c1406368398b6afa67454c9b568f80cad139924e4f8d0851c73e786edd1d80f81a08786c9b1ad3107620209b942c5463f8c671
7
- data.tar.gz: b7c81a31ec4a001c626e0d586e98fc4f22c37b844f359f01578cc0148b69d6834788c4a16a3f739d4d3cec60f109d4d40eeca592ff551b04e418c8a18429be9c
6
+ metadata.gz: 65426e9861152f2794e2817f70983fed0c9c918f3c24fd819f92aa1353fc28d122c4573b0c4e68ce8953d7dcb7ff5de170d38b6eab6969c71d77fa0ad6b0d75c
7
+ data.tar.gz: 9754add70dac2088baf9ee4c8b2fdb4e9f3f290043db9a9af358c323655e4f11d7f6aa0073506f4fe11b421c6f04fc650dd31ce58175d298cd1cbeb7664b4d57
@@ -9,21 +9,26 @@ module EffectiveEmailTemplatesMailer
9
9
 
10
10
  assigns = (@assigns || {})
11
11
 
12
- # Parse assigns. Special keys for body and subject.
12
+ # Parse body content if given
13
13
  body = assigns.delete(:body) || headers[:body] || headers['body']
14
14
  email_template.body = body if body.present?
15
15
 
16
- # Ignore the subject when passed in via mail method subject: key.
16
+ # Parse subject content if explicitly given
17
+ # Otherwise the :subject key is a default and should be ignored in favor of the email template subject instead
17
18
  subject = assigns.delete(:subject)
19
+ subject ||= (headers[:subject] || headers['subject']) if (headers[:custom_subject] || headers['custom_subject'])
18
20
  email_template.subject = subject if subject.present?
19
21
 
20
22
  # Add any _url helpers
21
23
  assigns = route_url_assigns(email_template, assigns).merge(assigns)
22
24
 
23
- # Render from the template, possibly with updated body
25
+ # Render from the template, possibly with updated body and subject
24
26
  rendered = email_template.render(assigns)
25
27
 
26
- super(rendered.merge(headers.except(:body, :subject, 'body', 'subject')))
28
+ # Merge any other passed values
29
+ merged = rendered.merge(headers.except(:body, :subject, :custom_subject, 'body', 'subject', 'custom_subject'))
30
+
31
+ super(merged)
27
32
  end
28
33
 
29
34
  private
@@ -53,7 +53,8 @@ module EffectiveEmailTemplates
53
53
  content.gsub(match[1], '').strip if match
54
54
  end
55
55
 
56
- from = froms.find { |from| from.include?(attributes['from']) } || froms.first
56
+ from = froms.find { |from| from.include?(attributes['from']) } if attributes['from'].present?
57
+ from ||= froms.first
57
58
 
58
59
  email_template.assign_attributes(attributes)
59
60
  email_template.assign_attributes(from: from)
@@ -1,3 +1,3 @@
1
1
  module EffectiveEmailTemplates
2
- VERSION = '1.5.0'.freeze
2
+ VERSION = '1.6.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_email_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect