guachiman 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/guachiman.rb +1 -0
- data/lib/guachiman/permissions.rb +1 -1
- data/lib/guachiman/strong_parameters.rb +33 -0
- data/lib/guachiman/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e800c68b0ed65758b2d1c4f48e37ed9934c3e19
|
4
|
+
data.tar.gz: dde75fbbbc432e64e3454b138358f93c20aa24f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a4ac42c31cd4fb7148fe705165118f78e2f69fa151811b699866242d9ac93e19929ea0aa2eaa0db2cec9e75bc76f39734d03d6317c52e22ef919cf239371d72
|
7
|
+
data.tar.gz: 2dc35a2574b6e7cf82d12b5ed9ceb051c771a97b34d4397d7f0fb2a9662dc2f2da229fb2463be1207ed37839d75e2c79279639cea72ec0e0e59dbc918580bbc0
|
data/lib/guachiman.rb
CHANGED
@@ -3,7 +3,7 @@ module Guachiman
|
|
3
3
|
attr_reader :allowed_actions, :allow_all
|
4
4
|
|
5
5
|
def allow controllers, actions, &block
|
6
|
-
@allowed_actions ||=
|
6
|
+
@allowed_actions ||= {}
|
7
7
|
Array(controllers).each do |controller|
|
8
8
|
Array(actions).each do |action|
|
9
9
|
allowed_actions[controller] ||= {}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Guachiman
|
2
|
+
module StrongParameters
|
3
|
+
attr_reader :allowed_params
|
4
|
+
|
5
|
+
def allow_param resources, attributes
|
6
|
+
@allowed_params ||= {}
|
7
|
+
Array(resources).each do |resource|
|
8
|
+
allowed_params[resource] ||= []
|
9
|
+
allowed_params[resource] += Array(attributes)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def allow_param?(resource, attribute)
|
14
|
+
if @allow_all
|
15
|
+
true
|
16
|
+
elsif @allowed_params && @allowed_params[resource]
|
17
|
+
@allowed_params[resource].include? attribute
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def permit_params! params
|
22
|
+
if @allow_all
|
23
|
+
params.permit!
|
24
|
+
elsif allowed_params
|
25
|
+
allowed_params.each do |resource, attributes|
|
26
|
+
if params[resource].respond_to? :permit
|
27
|
+
params[resource] = params[resource].permit(*attributes)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/guachiman/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guachiman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Rodriguez
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/guachiman/permissions.rb
|
103
103
|
- lib/guachiman/rails/permissible.rb
|
104
104
|
- lib/guachiman/rails/railtie.rb
|
105
|
+
- lib/guachiman/strong_parameters.rb
|
105
106
|
- lib/guachiman/version.rb
|
106
107
|
- test/generators/install_generator_test.rb
|
107
108
|
- test/test_helper.rb
|