Module: RoleClass::ClassMethods

Included in:
Role
Defined in:
lib/roles_data_mapper/role.rb

Instance Method Summary collapse

Instance Method Details

#find_role(role_name) ⇒ Object

Raises:

  • (ArgumentError)


22
23
24
25
26
# File 'lib/roles_data_mapper/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_data_mapper/role.rb', line 18

def find_roles(*role_names)
  all(:name => role_names.flatten)
end