Class: Role

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document
Defined in:
lib/roles_mongoid/role.rb

Class Method Summary collapse

Class Method Details

.find_role(role_name) ⇒ Object

Raises:

  • (ArgumentError)


22
23
24
25
26
# File 'lib/roles_mongoid/role.rb', line 22

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



18
19
20
# File 'lib/roles_mongoid/role.rb', line 18

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