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 +4 -4
- data/app/models/concerns/acts_as_role_restricted.rb +4 -0
- data/lib/effective_roles/version.rb +1 -1
- data/lib/effective_roles.rb +6 -5
- 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: 8c4f356993f7be2c1a6e89929a4fe5f2a20299479635f8f4f35b8f77f5739b75
|
4
|
+
data.tar.gz: 6b99770ddd3141c5eb7329f8f8474b8b81f202540f0059be99ae20f0dd6dba09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da6be1b61232cdfb73e8febac700dfb6e7b05a5043d2fcf0a00058d7584072468cc016294f236df0f3198dfbe4f073ecdf74ae4a202c70d3fd6cefb475bed3d7
|
7
|
+
data.tar.gz: 4b25753fd844cdb353bc3166b83d5ceca6d359c071fd9434d07a90bc3d346ba9eda9a3b3d66b36af173280b4a6c37c6fd33d705d5839affe30322e71f35bc733
|
data/lib/effective_roles.rb
CHANGED
@@ -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,
|
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
|
-
|
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
|
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.
|
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:
|
11
|
+
date: 2025-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|