effective_roles 2.7.1 → 2.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c1f1f6b5dd1700dcaa93ac9b8f57ffbdd20a131be00bded8702b5f07fa65f30
4
- data.tar.gz: c1e9fca0b2f63631519bd7a2f3cae7c5ff8ca3bb51e867a163f4f8830f511190
3
+ metadata.gz: 8c4f356993f7be2c1a6e89929a4fe5f2a20299479635f8f4f35b8f77f5739b75
4
+ data.tar.gz: 6b99770ddd3141c5eb7329f8f8474b8b81f202540f0059be99ae20f0dd6dba09
5
5
  SHA512:
6
- metadata.gz: f00b6ad97bef4ec78ebc2b14b80e2ac0c3433e7bbda3cc40904339e0029af67e2bd90fd17f66e2ee71a2dc74f04432a9fddbad48074cd854affcd7b5e3d6db68
7
- data.tar.gz: f3113726bb54b14fcf9c4a0224e82c504fb9854a138d79f3b5fd664aa0e4e2c7ec8e92e1483f3ac9834307f5e7d0a7cf87fc68bbdd9aea1dad052354ca4af069
6
+ metadata.gz: da6be1b61232cdfb73e8febac700dfb6e7b05a5043d2fcf0a00058d7584072468cc016294f236df0f3198dfbe4f073ecdf74ae4a202c70d3fd6cefb475bed3d7
7
+ data.tar.gz: 4b25753fd844cdb353bc3166b83d5ceca6d359c071fd9434d07a90bc3d346ba9eda9a3b3d66b36af173280b4a6c37c6fd33d705d5839affe30322e71f35bc733
@@ -165,4 +165,8 @@ module ActsAsRoleRestricted
165
165
  roles.present?
166
166
  end
167
167
 
168
+ def roles_was
169
+ EffectiveRoles.roles_for(roles_mask_was)
170
+ end
171
+
168
172
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveRoles
2
- VERSION = '2.7.1'.freeze
2
+ VERSION = '2.8.1'.freeze
3
3
  end
@@ -44,7 +44,7 @@ module EffectiveRoles
44
44
  (role_colors || {})[role]
45
45
  end
46
46
 
47
- def self.roles_collection(resource, current_user = nil, only: nil, except: nil, multiple: nil, skip_disabled: nil)
47
+ def self.roles_collection(resource, current_user = nil, only: nil, except: nil, skip_disabled: nil)
48
48
  if assignable_roles.present?
49
49
  raise('expected object to respond to is_role_restricted?') unless resource.respond_to?(:is_role_restricted?)
50
50
  raise('expected current_user to respond to is_role_restricted?') if current_user && !current_user.respond_to?(:is_role_restricted?)
@@ -52,11 +52,12 @@ module EffectiveRoles
52
52
 
53
53
  only = Array(only).compact
54
54
  except = Array(except).compact
55
- multiple = resource.acts_as_role_restricted_options[:multiple] if multiple.nil?
56
- assignable = assignable_roles_collection(resource, current_user, multiple: multiple)
57
55
  skip_disabled = assignable_roles.kind_of?(Hash) if skip_disabled.nil?
58
56
 
59
- roles.map do |role|
57
+ all_roles = assignable_roles_collection(resource)
58
+ assignable = assignable_roles_collection(resource, current_user)
59
+
60
+ all_roles.map do |role|
60
61
  next if only.present? && !only.include?(role)
61
62
  next if except.present? && except.include?(role)
62
63
 
@@ -71,7 +72,7 @@ module EffectiveRoles
71
72
  end.compact
72
73
  end
73
74
 
74
- def self.assignable_roles_collection(resource, current_user = nil, multiple: nil)
75
+ def self.assignable_roles_collection(resource, current_user = nil)
75
76
  return roles unless assignable_roles_present?(resource)
76
77
 
77
78
  if current_user && !current_user.respond_to?(:is_role_restricted?)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_roles
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.1
4
+ version: 2.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-17 00:00:00.000000000 Z
11
+ date: 2025-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails