effective_resources 1.14.0 → 1.15.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4196a26392312c2343b4ae31d4580a7c8b84a8f37d8e74c77e17d34016314b9c
|
4
|
+
data.tar.gz: 93d48690d2be56b1f5068bf815055de47446599b82aaf4444e52583208f368b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b25bc7b63e988fe7198cdd2e5b44d79cbee612fb18839b088feb7e3c53c6b00a8c27ac76f0de796278f147e93b27d64f374cae0c00e1419350146243cfc4f9ae
|
7
|
+
data.tar.gz: 159c99e620737423d67963b28feefa1bda55dfd645a25835892bded90a4d616dd52e659913f3f97f246c6274a5ad5cae615c33d43c795c576a8fe6465235487a
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Includes some shared mailer methods for effective_* gem mailers
|
2
|
+
|
3
|
+
module EffectiveMailer
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
default from: -> { mailer_settings.mailer_sender }
|
8
|
+
layout -> { mailer_settings.mailer_layout }
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def mailer_admin
|
14
|
+
mailer_settings.mailer_admin
|
15
|
+
end
|
16
|
+
|
17
|
+
def subject_for(action, subject, resource, opts = {})
|
18
|
+
mailer_subject = mailer_settings.mailer_subject
|
19
|
+
|
20
|
+
if mailer_subject.respond_to?(:call)
|
21
|
+
subject = self.instance_exec(action, subject, resource, opts, &mailer_subject)
|
22
|
+
end
|
23
|
+
|
24
|
+
subject
|
25
|
+
end
|
26
|
+
|
27
|
+
def headers_for(resource, opts = {})
|
28
|
+
(resource.respond_to?(:log_changes_datatable) ? opts.merge(log: resource) : opts)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# This returns the top level gem, EffectiveOrders or EffectiveResources
|
34
|
+
def mailer_settings
|
35
|
+
name = self.class.name.sub('::', '').sub('Mailer', '')
|
36
|
+
|
37
|
+
# If this is in a gem mailer like Effective::OrdersMailer we use constantize
|
38
|
+
# Otherwise this could be included in an ApplicationMailer, so we defer to EffectiveResources
|
39
|
+
klass = if name.start_with?('Effective')
|
40
|
+
name.constantize
|
41
|
+
else
|
42
|
+
name.safe_constantize || EffectiveResources
|
43
|
+
end
|
44
|
+
|
45
|
+
raise('expected mailer settings to respond to mailer_subject') unless klass.respond_to?(:mailer_subject)
|
46
|
+
raise('expected mailer settings to respond to mailer_sender') unless klass.respond_to?(:mailer_sender)
|
47
|
+
raise('expected mailer settings to respond to mailer_layout') unless klass.respond_to?(:mailer_layout)
|
48
|
+
|
49
|
+
klass
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -43,6 +43,9 @@ EffectiveResources.setup do |config|
|
|
43
43
|
# Default layout
|
44
44
|
# config.mailer_layout = 'effective_mailer_layout'
|
45
45
|
|
46
|
+
# Customize the Subject
|
47
|
+
# config.mailer_subject = Proc.new { |action, subject, resource, opts = {}| subject }
|
48
|
+
|
46
49
|
# Default From
|
47
50
|
config.mailer_sender = '"Info" <info@example.com>'
|
48
51
|
|
@@ -5,7 +5,7 @@ module EffectiveGem
|
|
5
5
|
|
6
6
|
EXCLUDED_GETTERS = [
|
7
7
|
:config, :setup, :send_email, :parent_mailer_class,
|
8
|
-
:deliver_method, :mailer_layout, :mailer_sender, :mailer_admin
|
8
|
+
:deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :mailer_subject
|
9
9
|
]
|
10
10
|
|
11
11
|
included do
|
@@ -72,6 +72,10 @@ module EffectiveGem
|
|
72
72
|
config[:mailer_admin].presence || EffectiveResources.mailer_admin
|
73
73
|
end
|
74
74
|
|
75
|
+
def mailer_subject
|
76
|
+
config[:mailer_subject].presence || EffectiveResources.mailer_subject
|
77
|
+
end
|
78
|
+
|
75
79
|
def send_email(email, *args)
|
76
80
|
raise('gem does not respond to mailer_class') unless respond_to?(:mailer_class)
|
77
81
|
raise('expected args to be an Array') unless args.kind_of?(Array)
|
data/lib/effective_resources.rb
CHANGED
@@ -3,11 +3,12 @@ require 'effective_resources/version'
|
|
3
3
|
require 'effective_resources/effective_gem'
|
4
4
|
|
5
5
|
module EffectiveResources
|
6
|
+
MAILER_SUBJECT_PROC = Proc.new { |action, subject, resource, opts = {}| subject }
|
6
7
|
|
7
8
|
def self.config_keys
|
8
9
|
[
|
9
10
|
:authorization_method, :default_submits,
|
10
|
-
:deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :
|
11
|
+
:parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :mailer_subject
|
11
12
|
]
|
12
13
|
end
|
13
14
|
|
@@ -44,10 +45,19 @@ module EffectiveResources
|
|
44
45
|
(rails.respond_to?(:active_job) && rails.active_job.queue_adapter) ? :deliver_later : :deliver_now
|
45
46
|
end
|
46
47
|
|
48
|
+
def self.parent_mailer_class
|
49
|
+
return config[:parent_mailer].constantize if config[:parent_mailer].present?
|
50
|
+
'::ApplicationMailer'.safe_constantize || 'ActionMailer::Base'.constantize
|
51
|
+
end
|
52
|
+
|
47
53
|
def self.mailer_layout
|
48
54
|
config[:mailer_layout] || 'effective_mailer_layout'
|
49
55
|
end
|
50
56
|
|
57
|
+
def self.mailer_subject
|
58
|
+
config[:mailer_subject] || MAILER_SUBJECT_PROC
|
59
|
+
end
|
60
|
+
|
51
61
|
def self.mailer_sender
|
52
62
|
config[:mailer_sender] || raise('effective resources mailer_sender missing. Add it to config/initializers/effective_resources.rb')
|
53
63
|
end
|
@@ -56,11 +66,6 @@ module EffectiveResources
|
|
56
66
|
config[:mailer_admin] || raise('effective resources mailer_admin missing. Add it to config/initializers/effective_resources.rb')
|
57
67
|
end
|
58
68
|
|
59
|
-
def self.parent_mailer_class
|
60
|
-
return config[:parent_mailer].constantize if config[:parent_mailer].present?
|
61
|
-
'::ApplicationMailer'.safe_constantize || 'ActionMailer::Base'.constantize
|
62
|
-
end
|
63
|
-
|
64
69
|
# Utilities
|
65
70
|
|
66
71
|
# This looks up the best class give the name
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- app/helpers/effective_resources_helper.rb
|
153
153
|
- app/helpers/effective_resources_private_helper.rb
|
154
154
|
- app/helpers/effective_resources_wizard_helper.rb
|
155
|
+
- app/mailers/concerns/effective_mailer.rb
|
155
156
|
- app/models/concerns/acts_as_archived.rb
|
156
157
|
- app/models/concerns/acts_as_email_form.rb
|
157
158
|
- app/models/concerns/acts_as_purchasable_wizard.rb
|