i_am_i_can 4.3.1 → 4.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52f2148f7b7693972fbf12b9f573967491caf3ee
4
- data.tar.gz: d1282f21e4d23e9ab713e58fea2b91a23790074a
3
+ metadata.gz: 519c1026eae5c7971fab21986634e180723d35f6
4
+ data.tar.gz: 9cc200adfab71617107fcc41ca4d639f5447d7bb
5
5
  SHA512:
6
- metadata.gz: 32175d334cfa85c56d7ef787ee2f4d5a3d8995df40e26f6311581e9995d0d1844c02cd8c54c884101647ed79f7ff3b7d03ee87763e2ed573f97c631f4f01f9e5
7
- data.tar.gz: eb09a250c1bb986a5ef19034d94e9cd53773a4bb5adc216436dd46f44c975b97a74facbce1fd22c70d59fe5e48bc4d8b7e04c709ed09dd20f3dae796c211ea64
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!.first.is_a?(i_am_i_can.permission_model)
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!.first.class.in?([ Symbol, String ])
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.flatten!, instances, name: names)
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.flatten!, to_be_assigned_names)
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!.first.class.in?([ Symbol, String ])
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!, i)
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
@@ -1,3 +1,3 @@
1
1
  module IAmICan
2
- VERSION = '4.3.1'
2
+ VERSION = '4.3.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i_am_i_can
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.1
4
+ version: 4.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhandao