ez-permissions 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/models/ez/permissions/model.rb +3 -3
- data/lib/ez/permissions/api/authorize.rb +2 -2
- data/lib/ez/permissions/api/models.rb +5 -5
- data/lib/ez/permissions/api/permissions.rb +2 -2
- data/lib/ez/permissions/dsl.rb +1 -1
- data/lib/ez/permissions/version.rb +1 -1
- data/lib/generators/ez/permissions/install_generator.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5514714fbd59dcc2567a76cf7170c88ba2493ad654aa232ee464b386d7d73ca9
|
4
|
+
data.tar.gz: 988f18fad5072711f3699cbd78386647822745975314ef57bb6ab4848ea66cf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 547ec67bb10c87d4d4b6c04258d1491afaa8cd1f4c85b17403502d82b29fc7574b2f96c2327d12064be5dd0385cc6cfc4395b635a9c88bba2cb7a5f97d33d91a
|
7
|
+
data.tar.gz: a24ca354fd87426c2fee1aa94b660e410886288218dcb29dfe4439e68735a7b582ea2c2627d54c6d74ee1fa9efdc7d64eb26efeb489af409bb46f960168e5e1d
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ Configuration interface allows you to change default behavior
|
|
31
31
|
```ruby
|
32
32
|
Ez::Permissions.configure do |config|
|
33
33
|
# If in generated migrations you changed table names, please configure them here:
|
34
|
-
config.
|
34
|
+
config.permissions_table_name = 'my_permissions'
|
35
35
|
config.roles_table_name = 'my_roles'
|
36
36
|
config.models_roles_table_name = 'my_model_roles'
|
37
37
|
config.permissions_roles_table_name = 'my_permissions_roles'
|
@@ -7,16 +7,16 @@ module Ez
|
|
7
7
|
def self.included(base)
|
8
8
|
base.has_many :assigned_roles,
|
9
9
|
class_name: 'Ez::Permissions::ModelRole',
|
10
|
-
as:
|
10
|
+
as: :model
|
11
11
|
|
12
12
|
base.has_many :roles,
|
13
13
|
-> { distinct },
|
14
|
-
through:
|
14
|
+
through: :assigned_roles,
|
15
15
|
class_name: 'Ez::Permissions::Role'
|
16
16
|
|
17
17
|
base.has_many :permissions,
|
18
18
|
-> { distinct },
|
19
|
-
through:
|
19
|
+
through: :roles,
|
20
20
|
class_name: 'Ez::Permissions::Permission'
|
21
21
|
end
|
22
22
|
# rubocop:enable Metrics/MethodLength
|
@@ -53,9 +53,9 @@ module Ez
|
|
53
53
|
permission_ids = Ez::Permissions::PermissionRole.where(role_id: role_ids).pluck(:permission_id)
|
54
54
|
|
55
55
|
Ez::Permissions::Permission.where(
|
56
|
-
id:
|
56
|
+
id: permission_ids,
|
57
57
|
resource: resource,
|
58
|
-
action:
|
58
|
+
action: actions.map(&:to_s)
|
59
59
|
)
|
60
60
|
end
|
61
61
|
|
@@ -8,8 +8,8 @@ module Ez
|
|
8
8
|
role = Ez::Permissions::API.get_role!(role_name)
|
9
9
|
|
10
10
|
Ez::Permissions::ModelRole.find_or_create_by!(
|
11
|
-
role:
|
12
|
-
model:
|
11
|
+
role: role,
|
12
|
+
model: model,
|
13
13
|
scoped: scoped
|
14
14
|
)
|
15
15
|
end
|
@@ -30,7 +30,7 @@ module Ez
|
|
30
30
|
role = Ez::Permissions::API.get_role!(role_name)
|
31
31
|
|
32
32
|
Ez::Permissions::ModelRole.where(
|
33
|
-
role:
|
33
|
+
role: role,
|
34
34
|
scoped: scoped
|
35
35
|
).map(&:model)
|
36
36
|
end
|
@@ -39,8 +39,8 @@ module Ez
|
|
39
39
|
|
40
40
|
def model_role(role, model, scoped)
|
41
41
|
Ez::Permissions::ModelRole.find_by(
|
42
|
-
role:
|
43
|
-
model:
|
42
|
+
role: role,
|
43
|
+
model: model,
|
44
44
|
scoped: scoped
|
45
45
|
)
|
46
46
|
end
|
@@ -28,7 +28,7 @@ module Ez
|
|
28
28
|
permission = get_permission!(action, resource)
|
29
29
|
|
30
30
|
Ez::Permissions::PermissionRole.find_by(
|
31
|
-
role:
|
31
|
+
role: role,
|
32
32
|
permission: permission
|
33
33
|
)&.delete
|
34
34
|
end
|
@@ -37,7 +37,7 @@ module Ez
|
|
37
37
|
|
38
38
|
def grant_single_permission(role, permission)
|
39
39
|
Ez::Permissions::PermissionRole.find_or_create_by!(
|
40
|
-
role:
|
40
|
+
role: role,
|
41
41
|
permission: permission
|
42
42
|
)
|
43
43
|
end
|
data/lib/ez/permissions/dsl.rb
CHANGED
@@ -8,7 +8,7 @@ module Ez
|
|
8
8
|
"# frozen_string_literal: true
|
9
9
|
|
10
10
|
Ez::Permissions.configure do |config|
|
11
|
-
# config.
|
11
|
+
# config.permissions_table_name = 'ez_permissions_permissions'
|
12
12
|
# config.roles_table_name = 'ez_permissions_roles'
|
13
13
|
# config.models_roles_table_name = 'ez_permissions_model_roles'
|
14
14
|
# config.permissions_roles_table_name = 'ez_permissions_permissions_roles'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ez-permissions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Volodya Sveredyuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ez-core
|