Sha256: ba04b98a61dbccd953f1c3e22ee126c0f8afeab047996ee1cf2a688ced0fb143
Contents?: true
Size: 861 Bytes
Versions: 16
Compression:
Stored size: 861 Bytes
Contents
require 'roles_mongoid/strategy/shared' class Symbol def admin? self == :admin end end module Roles::Mongoid module Strategy module Single include Shared # assigns first valid role from list of roles def add_roles *role_names new_roles = select_valid_roles(role_names) new_role = new_roles.first if !new_roles.empty? set_role new_role end # should remove the current single role (set = nil) # only if it is contained in the list of roles to be removed def remove_roles *role_names roles = role_names.flat_uniq set_empty_role if roles_diff(roles).empty? true end def roles_list raise 'the method #roles should be present' if !respond_to? :roles present_roles(roles) end end end end
Version data entries
16 entries across 16 versions & 2 rubygems