effective_resources 1.14.0 → 1.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/mailers/concerns/effective_mailer.rb +52 -0
- data/app/models/effective/resources/controller.rb +0 -2
- data/config/effective_resources.rb +3 -0
- data/lib/effective_resources/effective_gem.rb +5 -1
- data/lib/effective_resources/engine.rb +3 -5
- data/lib/effective_resources/version.rb +1 -1
- data/lib/effective_resources.rb +11 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e7d7a9ee482e38794221a01b428e01de652eb23b63c2b926eda018c47ae057c
|
4
|
+
data.tar.gz: 5a920c11ce61cf201a20b1a7b2fb946846d1f034ad4e9acb91253b6d0a8f6ce5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99d01c855370aa34ad51bc3bde24a11d6b57080616312b4ed8e9c066601ec7fb5275117327780a94f9d85ad81e9a9486c49be29dfcb429f4654b3cac64ce67cc
|
7
|
+
data.tar.gz: 3fcd18e60abdb8f8da2208a92c6547718611ad70f0018c7a43af831173da3ee44cdc1c5a3a6f033c54d6fe97d67c749b8ccfb01f8b52e46893b132b6a6a5aada
|
@@ -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
|
@@ -47,7 +47,6 @@ module Effective
|
|
47
47
|
action_name = action.to_s.titleize
|
48
48
|
|
49
49
|
if action == :destroy
|
50
|
-
next if buttons.values.find { |v| v[:action] == :archive }.present?
|
51
50
|
buttons['Delete'] = { action: action, default: true, 'data-method' => :delete, 'data-confirm' => "Really delete @resource?" }
|
52
51
|
else
|
53
52
|
buttons[action_name] = { action: action, default: true, 'data-method' => :delete, 'data-confirm' => "Really #{action_name} @resource?" }
|
@@ -101,7 +100,6 @@ module Effective
|
|
101
100
|
action_name = action.to_s.titleize
|
102
101
|
|
103
102
|
if action == :destroy
|
104
|
-
next if actions.find { |_, v| v[:action] == :archive }.present?
|
105
103
|
actions['Delete'] = { action: action, default: true, 'data-method' => :delete, 'data-confirm' => "Really delete @resource?" }
|
106
104
|
else
|
107
105
|
actions[action_name] = { action: action, default: true, 'data-method' => :delete, 'data-confirm' => "Really #{action_name} @resource?" }
|
@@ -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)
|
@@ -57,11 +57,9 @@ module EffectiveResources
|
|
57
57
|
# Register the acts_as_archived routes concern
|
58
58
|
# resources :things, concerns: :acts_as_archived
|
59
59
|
initializer 'effective_resources.routes_concern' do |app|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
#ActiveSupport.on_load :action_controller_base do
|
64
|
-
#end
|
60
|
+
app.config.to_prepare do
|
61
|
+
ActionDispatch::Routing::Mapper.include(ActsAsArchived::RoutesConcern)
|
62
|
+
end
|
65
63
|
end
|
66
64
|
|
67
65
|
# Register the flash_messages concern so that it can be called in ActionController
|
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.16.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-12 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
|