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