effective_resources 1.9.19 → 1.10.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: db61d9867c96af5ca8c727700ab2c453bfc05a61394640a0c625ea656fd8b2a2
4
- data.tar.gz: da861639cb20385b43db877442e77a17766b24ef416b127d211089cbe47e6879
3
+ metadata.gz: 0bc703e350cb8ca2e07dd5d9f0413f88bd15e98bab5d113e2696397e00af0732
4
+ data.tar.gz: d40aa7078d8ce692b7c5c7991b5c5ed2c06de95b0bf3602c5253b2b19affe6e6
5
5
  SHA512:
6
- metadata.gz: 9b8d7940d66b6982338170336ae87595e7943f43ea6df15b32b12acbbe6e02904e921cfbb1ac5bcca09587955a1cdf2c3d12667121ed105aba30e3f95245ca13
7
- data.tar.gz: 13446ebdf1422b9762442ea98a0f0902a4c8ed5fb82d784ee90a5e7b46f779782ef016bdbf5902cce13bc48f2358cc38651dc594ab9b044ff06226f426ddd0e0
6
+ metadata.gz: 1f5a322f0390678c9fc5834003621d73a42ab538cb3c904d942b68d44a57acb81cd5ad4601b722f8f8795e64930074ad4281a8f26baea4d798edc0b182eaa48b
7
+ data.tar.gz: efcd8d06e4889a5adce7a747eb207a0abfb920ae4f46981fd4de82ddeace22eb9ff2364fe1482c99ccff71d94d0d3393e986fd10fd2c6aa74059459ac583f06a
@@ -0,0 +1,7 @@
1
+ !!!
2
+ %html{style: 'background: #fff;'}
3
+ %head
4
+ %meta{:content => 'text/html; charset=UTF-8', 'http-equiv' => 'Content-Type'}
5
+
6
+ %body{style: 'background: #fff;'}
7
+ = yield
@@ -21,6 +21,8 @@ EffectiveResources.setup do |config|
21
21
  # end
22
22
  config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) }
23
23
 
24
+ # Default Submits
25
+ #
24
26
  # These default submit actions will be added to each controller
25
27
  # and rendered when calling effective_submit(f)
26
28
  # based on the controller, and its `submits` if any.
@@ -28,4 +30,22 @@ EffectiveResources.setup do |config|
28
30
  # Supported values: 'Save', 'Continue', and 'Add New'
29
31
  config.default_submits = ['Save', 'Continue', 'Add New']
30
32
 
33
+ # Email Settings
34
+ #
35
+ # The default mailer settings for all effective gems
36
+ #
37
+ # Configure the parent class responsible to send e-mails.
38
+ # config.parent_mailer = '::ApplicationMailer'
39
+
40
+ # Default deliver method
41
+ # config.deliver_method = :deliver_now
42
+
43
+ # Default layout
44
+ # config.mailer_layout = 'effective_mailer_layout'
45
+
46
+ # Default From
47
+ config.mailer_sender = "no-reply@example.com"
48
+
49
+ # Send Admin correspondence To
50
+ config.mailer_admin = "admin@example.com"
31
51
  end
@@ -38,6 +38,16 @@ module EffectiveGem
38
38
 
39
39
  true
40
40
  end
41
+
42
+ # This is included into every gem
43
+ # The gem may not have a mailer or use effective email templates
44
+ def send_email(email, *args)
45
+ raise('gem does not respond to mailer_class') unless respond_to?(:mailer_class)
46
+ raise('expected args to be an Array') unless args.kind_of?(Array)
47
+
48
+ mailer_class.send(email, *args).send(EffectiveResources.deliver_method)
49
+ end
50
+
41
51
  end
42
52
 
43
53
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.9.19'.freeze
2
+ VERSION = '1.10.0'.freeze
3
3
  end
@@ -5,7 +5,10 @@ require 'effective_resources/effective_gem'
5
5
  module EffectiveResources
6
6
 
7
7
  def self.config_keys
8
- [:authorization_method, :default_submits]
8
+ [
9
+ :authorization_method, :default_submits,
10
+ :deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :parent_mailer
11
+ ]
9
12
  end
10
13
 
11
14
  include EffectiveGem
@@ -31,6 +34,28 @@ module EffectiveResources
31
34
  (['Save', 'Continue', 'Add New'] & Array(config.default_submits)).inject({}) { |h, v| h[v] = true; h }
32
35
  end
33
36
 
37
+ # Email
38
+ def self.deliver_method
39
+ config[:deliver_method] || :deliver_now
40
+ end
41
+
42
+ def self.mailer_layout
43
+ config[:mailer_layout] || 'effective_mailer_layout'
44
+ end
45
+
46
+ def self.mailer_sender
47
+ config[:mailer_sender] || raise('effective resources mailer_sender missing. Add it to config/initializers/effective_resources.rb')
48
+ end
49
+
50
+ def self.mailer_admin
51
+ config[:mailer_admin] || raise('effective resources mailer_admin missing. Add it to config/initializers/effective_resources.rb')
52
+ end
53
+
54
+ def self.parent_mailer_class
55
+ return config[:parent_mailer].constantize if config[:parent_mailer].present?
56
+ '::ApplicationMailer'.safe_constantize || 'ActionMailer::Base'.constantize
57
+ end
58
+
34
59
  # Utilities
35
60
 
36
61
  # 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.9.19
4
+ version: 1.10.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-01-18 00:00:00.000000000 Z
11
+ date: 2022-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -202,6 +202,7 @@ files:
202
202
  - app/views/effective/resource/_actions.html.haml
203
203
  - app/views/effective/resource/_actions_dropleft.html.haml
204
204
  - app/views/effective/resource/_actions_glyphicons.html.haml
205
+ - app/views/layouts/effective_mailer_layout.html.haml
205
206
  - config/effective_resources.rb
206
207
  - lib/effective_resources.rb
207
208
  - lib/effective_resources/effective_gem.rb