mailtime 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mailtime/action_mailer/base.rb +22 -7
- data/lib/mailtime/active_record/models/concerns/mail_layout_concern.rb +1 -1
- data/lib/mailtime/active_record/models/concerns/mail_template_concern.rb +5 -6
- data/lib/mailtime/processor/mail_log_service.rb +1 -1
- data/lib/mailtime/processor/processor.rb +1 -1
- data/lib/mailtime/renderers/mail_renderer.rb +3 -3
- data/lib/mailtime/renderers/null.rb +4 -2
- data/lib/mailtime/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 002fb9cd610aa3981cf339df70530af08af43225
|
4
|
+
data.tar.gz: 63b2c8ba97369f4332dcf7304a44ec17176ab157
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec3cc6edb99157a6f6b0a91f510e65277b40b58b8a9c1d68136d1363f7f9fbd575ea6b41dcf524f41c214bc3bccd4e2daa2ed3185b2aa8e44daf79dfc754fa9e
|
7
|
+
data.tar.gz: d06eef854c7a18f7cf11195deab491d569f523f997b8fc5a69ce4fb602eb0db2280d04b9504e662d91f218ed908258b675772714f32d5c8013465223f2492d2f
|
@@ -17,28 +17,43 @@ module Mailtime
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
+
# inject some stuff.
|
21
|
+
# to avoid a mostly useless service object, add the mailtime_template and mailtime_layout
|
20
22
|
def inject_metadata
|
21
23
|
mailer_klass = self.class.to_s
|
22
24
|
mailer_action = self.action_name
|
23
25
|
action_variables = self.instance_variables_map
|
24
26
|
|
25
27
|
self.message.instance_variable_set(:@mailer_klass, mailer_klass)
|
26
|
-
self.message.instance_variable_set(:@mailer_action, mailer_action)
|
27
|
-
self.message.instance_variable_set(:@action_variables, action_variables)
|
28
|
-
self.message.instance_variable_set(:@template_path, self.headers[:template_path] || mailer_klass)
|
29
|
-
self.message.instance_variable_set(:@template_name, self.headers[:template_name] || mailer_action)
|
30
|
-
self.message.instance_variable_set(:@mailtime_template, nil)
|
31
|
-
self.message.instance_variable_set(:@mailtime_layout, nil)
|
32
|
-
|
33
28
|
self.message.class.send(:attr_reader, :mailer_klass)
|
29
|
+
|
30
|
+
self.message.instance_variable_set(:@mailer_action, mailer_action)
|
34
31
|
self.message.class.send(:attr_reader, :mailer_action)
|
32
|
+
|
33
|
+
self.message.instance_variable_set(:@action_variables, action_variables)
|
35
34
|
self.message.class.send(:attr_reader, :action_variables)
|
35
|
+
|
36
|
+
self.message.instance_variable_set(:@template_path, self.headers[:template_path] || mailer_klass)
|
36
37
|
self.message.class.send(:attr_reader, :template_path)
|
38
|
+
|
39
|
+
self.message.instance_variable_set(:@template_name, self.headers[:template_name] || mailer_action)
|
37
40
|
self.message.class.send(:attr_reader, :template_name)
|
41
|
+
|
42
|
+
self.message.instance_variable_set(:@mailtime_template, find_mailtime_template)
|
38
43
|
self.message.class.send(:attr_accessor, :mailtime_template)
|
44
|
+
|
45
|
+
self.message.instance_variable_set(:@mailtime_layout, find_mailtime_template.mailtime_mail_layout)
|
39
46
|
self.message.class.send(:attr_accessor, :mailtime_layout)
|
40
47
|
end
|
41
48
|
|
49
|
+
def find_mailtime_template
|
50
|
+
_template = Mailtime::MailTemplate.find_by(:klass => self.class.to_s, :action => self.action_name)
|
51
|
+
if _template.nil?
|
52
|
+
_template = Mailtime::NullTemplate.new(self)
|
53
|
+
end
|
54
|
+
_template
|
55
|
+
end
|
56
|
+
|
42
57
|
end
|
43
58
|
end
|
44
59
|
end
|
@@ -9,7 +9,7 @@ module Mailtime
|
|
9
9
|
self.table_name = 'mailtime_mail_layouts'
|
10
10
|
has_many :mail_templates, :class_name => 'Mailtime::MailTemplate'
|
11
11
|
|
12
|
-
|
12
|
+
validates_presence_of :format, :in => -> { Mailtime.configuration.valid_formats }
|
13
13
|
|
14
14
|
end
|
15
15
|
|
@@ -8,9 +8,9 @@ module Mailtime
|
|
8
8
|
included do
|
9
9
|
self.table_name = 'mailtime_mail_templates'
|
10
10
|
|
11
|
-
belongs_to :mail_layout, :class_name => 'Mailtime::MailLayout'
|
12
|
-
|
13
|
-
|
11
|
+
belongs_to :mail_layout, :class_name => 'Mailtime::MailLayout', :foreign_key => :mailtime_mail_layout_id
|
12
|
+
validates_presence_of :klass, :in => -> { mailers }
|
13
|
+
validates_presence_of :format, :in => -> { Mailtime.configuration.valid_formats }
|
14
14
|
validates_uniqueness_of :action, :scope => [:klass, :format]
|
15
15
|
|
16
16
|
def self.mailers
|
@@ -22,9 +22,8 @@ module Mailtime
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
|
27
|
-
self[:mail_layout]
|
25
|
+
def mailtime_mail_layout
|
26
|
+
self.mail_layout.present? ? self.mail_layout : NullLayout.new
|
28
27
|
end
|
29
28
|
|
30
29
|
def additional_headers
|
@@ -42,7 +42,7 @@ module Mailtime
|
|
42
42
|
@fields.each do |field|
|
43
43
|
::Mailtime::MailLog.create(
|
44
44
|
:loggable => @loggable,
|
45
|
-
:mailtime_mail_template_id => @
|
45
|
+
:mailtime_mail_template_id => @mail.mailtime_template.try(:id),
|
46
46
|
:action => @mail.mailer_action,
|
47
47
|
:klass => @mail.mailer_klass,
|
48
48
|
:headers => extract_headers,
|
@@ -4,8 +4,8 @@ module Mailtime
|
|
4
4
|
|
5
5
|
def initialize(mail)
|
6
6
|
@mail = mail
|
7
|
-
@template =
|
8
|
-
@layout =
|
7
|
+
@template = @mail.mailtime_template
|
8
|
+
@layout = @mail.mailtime_layout
|
9
9
|
end
|
10
10
|
|
11
11
|
def render
|
@@ -29,7 +29,7 @@ module Mailtime
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def find_layout
|
32
|
-
@template.
|
32
|
+
@template.mailtime_mail_layout
|
33
33
|
end
|
34
34
|
|
35
35
|
def render_and_merge
|
@@ -3,8 +3,9 @@
|
|
3
3
|
module Mailtime
|
4
4
|
class NullLayout
|
5
5
|
|
6
|
-
attr_reader :content
|
6
|
+
attr_reader :content, :id
|
7
7
|
def initialize
|
8
|
+
@id = nil
|
8
9
|
@content = "#{Mailtime.configuration.yield_keyword}"
|
9
10
|
end
|
10
11
|
|
@@ -24,8 +25,9 @@ module Mailtime
|
|
24
25
|
|
25
26
|
class NullTemplate
|
26
27
|
|
27
|
-
attr_reader :content
|
28
|
+
attr_reader :content, :id
|
28
29
|
def initialize(mail)
|
30
|
+
@id = nil
|
29
31
|
@content = mail.body.raw_source
|
30
32
|
end
|
31
33
|
|
data/lib/mailtime/version.rb
CHANGED