mirror of
https://github.com/Fishwaldo/role_model.git
synced 2025-03-15 11:32:04 +00:00
Replaces use of role.respond_to?(:each) with role.is_a?(Set) in mask_for.
This commit is contained in:
parent
3cefbf35da
commit
565e919863
1 changed files with 1 additions and 4 deletions
|
@ -19,10 +19,7 @@ module RoleModel
|
|||
end
|
||||
|
||||
def mask_for(*roles)
|
||||
sanitized_roles = roles.map { |role|
|
||||
role.respond_to?(:each) ? role.to_a : role
|
||||
}.flatten.map(&:to_sym)
|
||||
|
||||
sanitized_roles = roles.map { |role| role.is_a?(Set) ? role.to_a : role }.flatten.map(&:to_sym)
|
||||
(valid_roles & sanitized_roles).inject(0) { |sum, role| sum + 2**valid_roles.index(role) }
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue