rbac_core 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbac_core/computed_permissions.rb +32 -0
- data/lib/rbac_core/permission_set.rb +4 -4
- data/lib/rbac_core/version.rb +1 -1
- data/lib/rbac_core.rb +1 -0
- 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: e20bafe41484d58cc983f772cbf6e8da5e2a5fc2
|
4
|
+
data.tar.gz: 46c6e5d9e333fc34b50509ab8af8ae307e5956a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14ea6df4a18e99d68f7d1dbfbf1241ca8791e34e426d1f59c5b857cce9d09acaf8cf1435b0405aebb5956a0522fcde04a862707cc2561320fc7004090cef923f
|
7
|
+
data.tar.gz: edf91774d3b6e340a7d854fb5806ed73f3fc49789797a0b52c101d62fa04f94d1260745bf614bce40400cdc8856a7936328c6df9019f155f3d12cbb139a1094e
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RbacCore
|
2
|
+
class ComputedPermissions
|
3
|
+
delegate :each, :map, :to_a, :to_ary, to: :@permissions
|
4
|
+
|
5
|
+
def initialize(permissions = [])
|
6
|
+
@permissions = [].concat permissions.to_a
|
7
|
+
regroup!
|
8
|
+
end
|
9
|
+
|
10
|
+
def concat(permissions)
|
11
|
+
@permissions.concat permissions
|
12
|
+
regroup!
|
13
|
+
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(context, *args)
|
18
|
+
@permissions.each do |permission|
|
19
|
+
permission.call(context, *args)
|
20
|
+
end
|
21
|
+
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def regroup!
|
28
|
+
@permissions.uniq!
|
29
|
+
@permissions.sort_by!(&:priority)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -7,10 +7,10 @@ module RbacCore
|
|
7
7
|
def permitted_permissions(include_nested: true)
|
8
8
|
permissions = self.class.registered_permissions.slice(*permitted_permission_names).values
|
9
9
|
if include_nested && nested_attributes.any?
|
10
|
-
permissions
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
permissions.concat nested_attributes.values.map(&:permitted_permissions).flatten!
|
11
|
+
end
|
12
|
+
|
13
|
+
ComputedPermissions.new(permissions)
|
14
14
|
end
|
15
15
|
|
16
16
|
class << self
|
data/lib/rbac_core/version.rb
CHANGED
data/lib/rbac_core.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbac_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jasl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- app/models/rbac_core/role.rb
|
53
53
|
- db/migrate/20170705174003_create_rbac_core_roles.rb
|
54
54
|
- lib/rbac_core.rb
|
55
|
+
- lib/rbac_core/computed_permissions.rb
|
55
56
|
- lib/rbac_core/concerns/models/role.rb
|
56
57
|
- lib/rbac_core/engine.rb
|
57
58
|
- lib/rbac_core/mapper.rb
|