role_core 0.0.23 → 0.0.25
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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/db/migrate/20170705174003_create_roles.rb +2 -0
- data/lib/role_core/contrib/can_can_can_permission.rb +7 -4
- data/lib/role_core/version.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 588687072ceb69fb165d2c7f86d8bb0dae0c814d33049221466dc4c0adcacfb0
|
4
|
+
data.tar.gz: 2c0cf9515890e0389246d4fb4f570b3f39aae95781ad616d0c6306917df25a55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c1419d298d3664ea384f88d68db83fd4209bda7827e826ede86c5720d170b3d83874e8df9650917a5ca93dac0ff79c4bda3a5f1e7d67c1cc292396ef46d6a14
|
7
|
+
data.tar.gz: 83d4392b01a8766946f8c1e8fd1695d481f351d24628feab71724982c0c7d883b5b691ea961e29e73809ff73974fbcaab4c1158772a392ebd8d5ae56aecf3f52
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ Open your browser, and visit `http://localhost:3000`
|
|
47
47
|
|
48
48
|
The essence of RBAC is the role, despite your application, there are many possibilities: single-role, multi-roles, extendable-role and the role may associate to different kinds of resources (e.g: users and groups)
|
49
49
|
|
50
|
-
RoleCore provides
|
50
|
+
RoleCore provides an essential definition of Role,
|
51
51
|
you have to add association to adapt to your application,
|
52
52
|
for example:
|
53
53
|
|
@@ -368,7 +368,7 @@ By design, RoleCore is for static permissions, but dynamic permissions is easy t
|
|
368
368
|
|
369
369
|
The key is `RoleCore::PermissionSet#derive`, that will generate a new anonymous sub-class of `PermissionSet`.
|
370
370
|
|
371
|
-
|
371
|
+
Here's an example:
|
372
372
|
|
373
373
|
- Design a model to persisting dynamic permissions, e.g `DynamicPermission(id: bigint, name: string, default: bool)`
|
374
374
|
- Add `dynamic_permissions` column (`text` type) to Role model to persisting dynamic permissions' configuration, and in your model `serialize :dynamic_permissions, Hash`
|
@@ -9,20 +9,23 @@ module RoleCore
|
|
9
9
|
return unless _callable
|
10
10
|
|
11
11
|
@model_name = options[:model_name]
|
12
|
+
@subject = options[:subject]
|
12
13
|
@action = options[:action] || name
|
13
|
-
@options = options.except(:model, :model_name, :action)
|
14
|
+
@options = options.except(:model, :model_name, :subject, :action)
|
14
15
|
@block = block
|
15
16
|
end
|
16
17
|
|
17
18
|
def call(context, *args)
|
18
19
|
return unless callable
|
19
20
|
|
20
|
-
|
21
|
+
subject = @subject || @model_name.constantize
|
21
22
|
if block_attached?
|
22
|
-
context.can @action,
|
23
|
+
context.can @action, subject, &@block.curry[*args]
|
23
24
|
else
|
24
|
-
context.can @action,
|
25
|
+
context.can @action, subject, @options
|
25
26
|
end
|
27
|
+
rescue NameError
|
28
|
+
raise "You must provide a valid model name."
|
26
29
|
end
|
27
30
|
|
28
31
|
def block_attached?
|
data/lib/role_core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: role_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jasl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '5'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '7'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,14 +29,14 @@ dependencies:
|
|
29
29
|
version: '5'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '7'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: options_model
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.0.
|
39
|
+
version: 0.0.12
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '1.0'
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.0.
|
49
|
+
version: 0.0.12
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '1.0'
|
@@ -100,8 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
|
-
|
104
|
-
rubygems_version: 2.7.7
|
103
|
+
rubygems_version: 3.0.3
|
105
104
|
signing_key:
|
106
105
|
specification_version: 4
|
107
106
|
summary: RoleCore is a Rails engine which could provide essential industry of Role-based
|