Class: Role

Inherits:
Object
  • Object
show all
Extended by:
RoleClass::ClassMethods
Includes:
Mongoid::Document
Defined in:
lib/roles_mongoid/role.rb,
lib/roles_mongoid/embedded_role.rb

Class Method Summary collapse

Methods included from RoleClass::ClassMethods

find_role, find_roles

Class Method Details

.find_role(role_name) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
# File 'lib/roles_mongoid/embedded_role.rb', line 18

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



14
15
16
# File 'lib/roles_mongoid/embedded_role.rb', line 14

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