effective_roles 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/effective_roles/version.rb +1 -1
- data/lib/effective_roles.rb +6 -2
- 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: c7ff9e1eeeb8d78b3f50617feee6d0de9d591478bb8a8cc69f11d2a94bb7c4d0
|
4
|
+
data.tar.gz: 66289a8ec1e2206d24a3e612b43b1da5e34311fdaff50973d7995b23052d5ee8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc6fccdfa2a4e1b534218b0d37ca175e6b5e339bc493130569ee3e0649c4a4505e52d358d28be3ab2de90c9b2cc7f74beb4c8fed9afffaadc2ab7f3877ed5e33
|
7
|
+
data.tar.gz: 0a5c756b3e12e9dd69c156ba2fe8360dd7caf3612a623641c45f08bf18b8fcffe9790687bf344141cd149f877907b41fbb9a2f0270a4546dbf3e555b031e7a66
|
data/lib/effective_roles.rb
CHANGED
@@ -39,7 +39,7 @@ module EffectiveRoles
|
|
39
39
|
roles_for(roles).map { |r| 2 ** config.roles.index(r) }.sum
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.roles_collection(resource, current_user = nil, only: nil, except: nil, multiple: nil)
|
42
|
+
def self.roles_collection(resource, current_user = nil, only: nil, except: nil, multiple: nil, skip_disabled: nil)
|
43
43
|
if assignable_roles.present?
|
44
44
|
raise('expected object to respond to is_role_restricted?') unless resource.respond_to?(:is_role_restricted?)
|
45
45
|
raise('expected current_user to respond to is_role_restricted?') if current_user && !current_user.respond_to?(:is_role_restricted?)
|
@@ -49,15 +49,19 @@ module EffectiveRoles
|
|
49
49
|
except = Array(except).compact
|
50
50
|
multiple = resource.acts_as_role_restricted_options[:multiple] if multiple.nil?
|
51
51
|
assignable = assignable_roles_collection(resource, current_user, multiple: multiple)
|
52
|
+
skip_disabled = assignable_roles.kind_of?(Hash) if skip_disabled.nil?
|
52
53
|
|
53
54
|
roles.map do |role|
|
54
55
|
next if only.present? && !only.include?(role)
|
55
56
|
next if except.present? && except.include?(role)
|
56
57
|
|
58
|
+
disabled = !assignable.include?(role)
|
59
|
+
next if disabled && skip_disabled
|
60
|
+
|
57
61
|
[
|
58
62
|
"#{role}<p class='help-block text-muted'>#{role_description(role, resource)}</p>".html_safe,
|
59
63
|
role,
|
60
|
-
({:disabled => :disabled}
|
64
|
+
({:disabled => :disabled} if disabled)
|
61
65
|
]
|
62
66
|
end.compact
|
63
67
|
end
|
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.2.
|
4
|
+
version: 2.2.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: 2021-
|
11
|
+
date: 2021-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|