Sha256: 843d66ed776ad59a12cc0e1294a838a5f5f9a5e902147ae1d92f0ef7ec484e35
Contents?: true
Size: 872 Bytes
Versions: 19
Compression:
Stored size: 872 Bytes
Contents
require 'roles_active_record/strategy/shared' class Symbol def admin? self == :admin end end module Roles::ActiveRecord 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
19 entries across 19 versions & 1 rubygems