Module: RoleClass::ClassMethods

Included in:
Role
Defined in:
lib/roles_mongoid/base_role.rb

Instance Method Summary collapse

Instance Method Details

#find_role(role_name) ⇒ Object

Raises:

  • (ArgumentError)


21
22
23
24
25
# File 'lib/roles_mongoid/base_role.rb', line 21

def find_role role_name
  raise ArgumentError, "#find_role takes a single role name as argument, not: #{role_name.inspect}" if !role_name.kind_of_label?
  res = find_roles(role_name)
  res ? res.first : res
end

#find_roles(*role_names) ⇒ Object



17
18
19
# File 'lib/roles_mongoid/base_role.rb', line 17

def find_roles(*role_names)
  where(:name.in => role_names.flatten).to_a
end