effective_resources 1.2.5 → 1.2.6

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
- SHA256:
3
- metadata.gz: ae9635ad1328b7109aaaf6250dd6e73b1e82c94883a26128f6c175dfaa541d2d
4
- data.tar.gz: 5921dbfd7773c0b1eb440b2864de2b1f1c95f0ec0d0de543de70433f185ed165
2
+ SHA1:
3
+ metadata.gz: a5581c1ca7e6f7a54decd9c6ea534aec3a9c61c4
4
+ data.tar.gz: ef4bbf6529ccff4299b90645e081379ef4953619
5
5
  SHA512:
6
- metadata.gz: 973334cca43d4337328170e7b97f95d2e97d678d24181c067d7f7e1e0c2cd81f79154a8c3c29745fbdace515cb8ea77c53dbbf313804e5331f8f36dc8270b4ab
7
- data.tar.gz: 43e5b2f690eac1dbd8b81cb9fbf54f2f3efa95b8886c15cce725b6f6299d4acfca795ef92e4d235caf3189bb3a944beb62e5cd51a4212f6694594c02fa574ef3
6
+ metadata.gz: a2d4d1a86fab8cfeb839226e621ac3c3be2b6818fb0d9d2e77e8da847e992ce44a46426b32c7f9c5b446f400152199446517ed122c13ca161d3b63c08befc3c5
7
+ data.tar.gz: 2a4d94ed4a0dc9f5f49c7c4ca29d6b84dd5946510b3be812e7bfd0a1dbeb43015484bdf51e605fd6f521705021216adf01b21b50cab992d1a92fdd63cfb8a3c3
@@ -6,6 +6,7 @@ module Effective
6
6
  submit = commit_action(action)
7
7
  redirect = submit[:redirect].respond_to?(:call) ? instance_exec(&submit[:redirect]) : submit[:redirect]
8
8
 
9
+ # If we have a specific redirect for it
9
10
  commit_action_redirect = case redirect
10
11
  when :index ; resource_index_path
11
12
  when :edit ; resource_edit_path
@@ -14,29 +15,42 @@ module Effective
14
15
  when :duplicate ; resource_duplicate_path
15
16
  when :back ; referer_redirect_path
16
17
  when :save ; [resource_edit_path, resource_show_path].compact.first
17
- when Symbol ; resource_action_path(submit[:action])
18
+ when Symbol ; resource_action_path(redirect)
18
19
  when String ; redirect
19
20
  else ; nil
20
21
  end
21
22
 
22
23
  return commit_action_redirect if commit_action_redirect.present?
23
24
 
24
- if action == :destroy
25
- return [referer_redirect_path, resource_index_path, root_path].compact.first
26
- end
27
-
28
- case params[:commit].to_s
29
- when 'Save'
25
+ # If we have a magic name
26
+ commit_name_redirect = case params[:commit].to_s
27
+ when 'Save and Add New', 'Add New'
28
+ [resource_new_path, resource_index_path]
29
+ when 'Duplicate'
30
+ [resource_duplicate_path, resource_index_path]
31
+ when 'Continue', 'Save and Continue'
32
+ [resource_index_path]
33
+ else
34
+ []
35
+ end.compact.first
36
+
37
+ return commit_name_redirect if commit_name_redirect.present?
38
+
39
+ # Otherwise consider the action
40
+ commit_default_redirect = case action
41
+ when :create
42
+ [resource_show_path, resource_edit_path, resource_index_path]
43
+ when :update
30
44
  [resource_edit_path, resource_show_path, resource_index_path]
31
- when 'Save and Add New', 'Add New'
32
- [resource_new_path, resource_index_path]
33
- when 'Duplicate'
34
- [resource_duplicate_path, resource_index_path]
35
- when 'Continue', 'Save and Continue'
36
- [resource_index_path]
45
+ when :destroy
46
+ [referer_redirect_path, resource_index_path]
37
47
  else
38
48
  [referer_redirect_path, resource_edit_path, resource_show_path, resource_index_path]
39
- end.compact.first.presence || root_path
49
+ end.compact.first
50
+
51
+ return commit_default_redirect if commit_default_redirect.present?
52
+
53
+ root_path
40
54
  end
41
55
 
42
56
  def referer_redirect_path
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.2.5'.freeze
2
+ VERSION = '1.2.6'.freeze
3
3
  end
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.2.5
4
+ version: 1.2.6
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: 2019-03-12 00:00:00.000000000 Z
11
+ date: 2019-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 2.7.3
114
+ rubygems_version: 2.4.5.1
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: Make any controller an effective resource controller.