i_am_i_can 4.3.1 → 4.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/i_am_i_can/permission/assignment.rb +2 -2
- data/lib/i_am_i_can/permission/definition.rb +1 -1
- data/lib/i_am_i_can/role/assignment.rb +3 -3
- data/lib/i_am_i_can/role/definition.rb +1 -1
- data/lib/i_am_i_can/role_group/definition.rb +1 -1
- data/lib/i_am_i_can/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 519c1026eae5c7971fab21986634e180723d35f6
|
4
|
+
data.tar.gz: 9cc200adfab71617107fcc41ca4d639f5447d7bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68319a2d89a43ce758c8fec136284560ef9720f7e7dd1c770969d8e91982bb3cc43fea7737dae965bd9fc8033ad31814fa64f30f9eaba8bc4ef460047c241569
|
7
|
+
data.tar.gz: ac8315de97eb469c52b0dca44230124a075733afc9c20a75bbe76578b1a3c5bc5fc0c95d2ce48e8ba25601aeb989935aef4b93ade1fe0f25185b8d02b4dd57a2
|
@@ -26,12 +26,12 @@ module IAmICan
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def _permissions_assignment(exec = :assign, actions, obj)
|
29
|
-
if actions.flatten
|
29
|
+
if actions.tap(&:flatten!).first.is_a?(i_am_i_can.permission_model)
|
30
30
|
exec_arg, names = actions, actions.map(&:name)
|
31
31
|
else
|
32
32
|
objs = obj ? Array(obj) : [nil]
|
33
33
|
permissions = actions.product(objs).map { |(p, o)| { action: p, **deconstruct_obj(o) }.values }
|
34
|
-
exec_arg = { action: permissions.map(&:first), obj_type: permissions.map { |v| v[1] }, obj_id: permissions.map(&:last) }
|
34
|
+
exec_arg = { action: permissions.map(&:first).uniq, obj_type: permissions.map { |v| v[1] }.uniq, obj_id: permissions.map(&:last).uniq }
|
35
35
|
names = permissions.map { |pms| pms.compact.join('_').to_sym }
|
36
36
|
end
|
37
37
|
|
@@ -2,7 +2,7 @@ module IAmICan
|
|
2
2
|
module Permission
|
3
3
|
module Definition
|
4
4
|
def have_permission *actions, obj: nil, remarks: nil
|
5
|
-
return unless actions.flatten
|
5
|
+
return unless actions.tap(&:flatten!).first.class.in?([ Symbol, String ])
|
6
6
|
objs = obj ? Array(obj) : [nil]
|
7
7
|
permissions = actions.product(objs).map { |(p, o)| { action: p, **deconstruct_obj(o), remarks: remarks } }
|
8
8
|
definition = _create_permissions(permissions)
|
@@ -35,13 +35,13 @@ module IAmICan
|
|
35
35
|
%i[ currently_is_a ].each { |aname| alias_method aname, :is_only_a }
|
36
36
|
|
37
37
|
def _roles_assignment(action = :assign, roles, save, exp: nil)
|
38
|
-
instances, names = Role.extract(roles, i_am_i_can)
|
38
|
+
instances, names = Role.extract(roles.flatten, i_am_i_can)
|
39
39
|
if save
|
40
|
-
assignment = _stored_roles_exec(action
|
40
|
+
assignment = _stored_roles_exec(action, instances, name: names)
|
41
41
|
_set_roles_expire(exp, assignment.map(&:id)) if exp
|
42
42
|
else
|
43
43
|
to_be_assigned_names = (instances.map(&:name).map(&:to_sym) + names).uniq
|
44
|
-
assignment = _temporary_roles_exec(action
|
44
|
+
assignment = _temporary_roles_exec(action, to_be_assigned_names)
|
45
45
|
end
|
46
46
|
|
47
47
|
ResultOf.role assignment, i_am_i_can, given: [instances, names]
|
@@ -2,7 +2,7 @@ module IAmICan
|
|
2
2
|
module Role
|
3
3
|
module Definition
|
4
4
|
def have_role *roles, which_can: [ ], obj: nil, remarks: nil
|
5
|
-
return unless roles.flatten
|
5
|
+
return unless roles.tap(&:flatten!).first.class.in?([ Symbol, String ])
|
6
6
|
roles.map!(&:to_sym) ; i = i_am_i_can
|
7
7
|
definition = _create_roles(roles.map { |role| { name: role, remarks: remarks } })
|
8
8
|
|
@@ -3,7 +3,7 @@ module IAmICan
|
|
3
3
|
module Definition
|
4
4
|
def group_roles *members, by_name:, which_can: [ ], obj: nil
|
5
5
|
group = (i = i_am_i_can).role_group_model.where(name: by_name).first_or_create
|
6
|
-
instances, names = Role.extract(members.flatten
|
6
|
+
instances, names = Role.extract(members.tap(&:flatten!), i)
|
7
7
|
assignment = group._members_exec(:assign, instances, name: names)
|
8
8
|
ResultOf.members assignment, i, given: [instances, names]
|
9
9
|
end
|
data/lib/i_am_i_can/version.rb
CHANGED