cant_cant_cant 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cant_cant_cant.rb +6 -4
- 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: 044a8b09b8b90ccb706fc099ae7157a2663db589
|
4
|
+
data.tar.gz: a4bed21f82d41c8618bb743091f655f08c3534e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cb4ee118ea0f164933bce0fdaa7daaaa4c260c2e10a55f6e17257d24eec9b414fb4ec979c545dc5589ef0201ab78b9fb9ecd81ed707081ac1e5da485f6a2bbb
|
7
|
+
data.tar.gz: 16922ea55999cb78a4c21946fdcba7e034e2d9b2ae11c3063a244eed424d1742ceacb4a4b93c32e89bdb934353eef6b61c249ca7feb7db401b4ce66a973ae30a
|
data/lib/cant_cant_cant.rb
CHANGED
@@ -25,9 +25,10 @@ module CantCantCant
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def permissions_for(roles)
|
28
|
+
roles = [roles] unless roles.is_a? Array
|
28
29
|
@cache[roles.sort.join(',')] ||=
|
29
30
|
permission_table
|
30
|
-
.values_at(*roles)
|
31
|
+
.values_at(*roles.map(:to_s))
|
31
32
|
.select(&:present?)
|
32
33
|
.map { |x| x.keep_if { |_, v| v == 'allow' }.keys }
|
33
34
|
.flatten
|
@@ -53,9 +54,10 @@ module CantCantCant
|
|
53
54
|
def inject_action(param)
|
54
55
|
controller_class, action = extract_controller(param)
|
55
56
|
controller_class.class_eval do
|
56
|
-
before_action(only:
|
57
|
-
|
58
|
-
|
57
|
+
before_action(only: action) do
|
58
|
+
roles = current_roles
|
59
|
+
next true if CantCantCant.allow?(param, roles)
|
60
|
+
raise PermissionDenied, [param, roles]
|
59
61
|
end
|
60
62
|
end
|
61
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cant_cant_cant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shou Ya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|