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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77423c072ab8659b9e632cebcd9fe939743abac4d0b374f12b3e144a70bcdfe1
4
- data.tar.gz: 929bbf885819e6303f7a09ffe7c58988f4607403903b3dfdc3c141f175714eee
3
+ metadata.gz: c7ff9e1eeeb8d78b3f50617feee6d0de9d591478bb8a8cc69f11d2a94bb7c4d0
4
+ data.tar.gz: 66289a8ec1e2206d24a3e612b43b1da5e34311fdaff50973d7995b23052d5ee8
5
5
  SHA512:
6
- metadata.gz: a6917b11179747ff215fd926a595594de592b6881a3ca74c7b699fb52a1a0b482259ff2edddd0cd02d2eaebf8d265ebea506128641d32fb7f296567bad2466bf
7
- data.tar.gz: 90a7d053382163c74cf8df9dee3d03b84239f4f39bd199d1b0ada04f124fd88b8ff4d7222dd8e3fce9f0eb37544c2bf386ab0a0d8c3a38ee9384b6b04b861907
6
+ metadata.gz: dc6fccdfa2a4e1b534218b0d37ca175e6b5e339bc493130569ee3e0649c4a4505e52d358d28be3ab2de90c9b2cc7f74beb4c8fed9afffaadc2ab7f3877ed5e33
7
+ data.tar.gz: 0a5c756b3e12e9dd69c156ba2fe8360dd7caf3612a623641c45f08bf18b8fcffe9790687bf344141cd149f877907b41fbb9a2f0270a4546dbf3e555b031e7a66
@@ -1,3 +1,3 @@
1
1
  module EffectiveRoles
2
- VERSION = '2.2.0'.freeze
2
+ VERSION = '2.2.1'.freeze
3
3
  end
@@ -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} unless assignable.include?(role))
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.0
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-06-21 00:00:00.000000000 Z
11
+ date: 2021-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails