cannibal 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cannibal/permission_registry.rb +21 -15
- metadata +4 -4
@@ -6,7 +6,6 @@ module Cannibal
|
|
6
6
|
|
7
7
|
def set(options)
|
8
8
|
actor = options[:actor]
|
9
|
-
verb = options[:verb]
|
10
9
|
subject = options[:subject]
|
11
10
|
|
12
11
|
if actor.is_a? Class
|
@@ -21,24 +20,31 @@ module Cannibal
|
|
21
20
|
subject_class = subject.class
|
22
21
|
end
|
23
22
|
|
23
|
+
perm = options[:perm]
|
24
24
|
actor_proc = options[:actor_proc]
|
25
25
|
gproc = options[:proc]
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
27
|
+
verbs = options[:verb]
|
28
|
+
verbs = [ verbs ] unless verbs.is_a? Array
|
29
|
+
|
30
|
+
verbs.each do |verb|
|
31
|
+
|
32
|
+
attributes = options[:attribute]
|
33
|
+
if attributes.nil?
|
34
|
+
# Set class-wide perms if no attributes specified
|
35
|
+
verb_hash(actor_class, subject_class, verb)[:perm] = perm unless perm.nil?
|
36
|
+
verb_hash(actor_class, subject_class, verb)[:actor_proc] = actor_proc unless actor_proc.nil?
|
37
|
+
verb_hash(actor_class, subject_class, verb)[:proc] = gproc unless gproc.nil?
|
38
|
+
else
|
39
|
+
attributes = [ attributes ] unless attributes.is_a? Array
|
40
|
+
attributes.each do |attribute|
|
41
|
+
attribute_hash(actor_class, subject_class, verb)[attribute] = {}
|
42
|
+
attribute_hash(actor_class, subject_class, verb)[attribute][:perm] = perm unless perm.nil?
|
43
|
+
attribute_hash(actor_class, subject_class, verb)[attribute][:actor_proc] = actor_proc unless actor_proc.nil?
|
44
|
+
attribute_hash(actor_class, subject_class, verb)[attribute][:proc] = gproc unless gproc.nil?
|
45
|
+
end
|
41
46
|
end
|
47
|
+
|
42
48
|
end
|
43
49
|
end
|
44
50
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cannibal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 1
|
10
|
+
version: 0.5.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Three Wise Men
|
@@ -34,7 +34,7 @@ files:
|
|
34
34
|
- lib/cannibal/subject.rb
|
35
35
|
- README.mdown
|
36
36
|
has_rdoc: true
|
37
|
-
homepage:
|
37
|
+
homepage: http://github.com/ThreeWiseMen/cannibal
|
38
38
|
licenses: []
|
39
39
|
|
40
40
|
post_install_message:
|