natural_resource 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/natural_resource/controller.rb +11 -4
- data/lib/natural_resource/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f70756513dff84d30377ac73a1868d4a2b62b07
|
4
|
+
data.tar.gz: 1e3b32e36b2b58c5484354ca7287e4986a915938
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cc835adeb493b048ff20840ada36b6782dd98cb745b06ef3b9f8dbe5cc899387977f7cebd25df1726e339c69abdd326387ae266bd7197657cf0d1bb2d15a2c4
|
7
|
+
data.tar.gz: 8c9bd2eae9d044a4f305c083efbe11f44374d0c9d3c4d9c4ba24001e6efc10513a2475ca7246e5f3f232099a9ed844c8fea77a38f4e7d1c6aa83098c9717fd62
|
@@ -10,7 +10,7 @@ module NaturalResource
|
|
10
10
|
include Pundit
|
11
11
|
|
12
12
|
class_methods do
|
13
|
-
def resource(resource_name)
|
13
|
+
def resource(resource_name, display_notices: true)
|
14
14
|
after_action :verify_authorized, except: :index
|
15
15
|
after_action :verify_policy_scoped
|
16
16
|
|
@@ -30,19 +30,19 @@ module NaturalResource
|
|
30
30
|
# POST /:controller_name
|
31
31
|
define_method :create do
|
32
32
|
resource.update! resource_params
|
33
|
-
|
33
|
+
success_redirect(:created)
|
34
34
|
end
|
35
35
|
|
36
36
|
# PUT /:controller_name/:id
|
37
37
|
define_method :update do
|
38
38
|
resource.tap { |r| r.update! resource_params }.touch
|
39
|
-
|
39
|
+
success_redirect(:updated)
|
40
40
|
end
|
41
41
|
|
42
42
|
# DELETE /:controller_name/:id
|
43
43
|
define_method :destroy do
|
44
44
|
resource.destroy
|
45
|
-
|
45
|
+
success_redirect(:deleted)
|
46
46
|
end
|
47
47
|
|
48
48
|
private
|
@@ -79,6 +79,13 @@ module NaturalResource
|
|
79
79
|
define_method :success_path do
|
80
80
|
url_for(action: :index)
|
81
81
|
end
|
82
|
+
|
83
|
+
define_method :success_redirect do |action|
|
84
|
+
redirect_options = {}
|
85
|
+
redirect_options.merge!({notice: "#{resource} was #{action}."}) if display_notices
|
86
|
+
|
87
|
+
redirect_to success_path, redirect_options
|
88
|
+
end
|
82
89
|
end
|
83
90
|
end
|
84
91
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: natural_resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert White
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|