Module: RoleStrategy::DataMapper::ManyRoles::ClassMethods

Defined in:
lib/roles_data_mapper/strategy/multi/many_roles.rb

Instance Method Summary collapse

Instance Method Details

#in_any_role(*roles) ⇒ Object



43
44
45
46
# File 'lib/roles_data_mapper/strategy/multi/many_roles.rb', line 43

def in_any_role(*roles)                          
  role_ids = Role.all(:name.in => roles.flatten).map{|role| role.id}
  all("user_roles.role_id" => role_ids)
end

#in_role(role_name) ⇒ Object



38
39
40
41
# File 'lib/roles_data_mapper/strategy/multi/many_roles.rb', line 38

def in_role(role_name)
  role = Role.all(:name => role_name).first
  all("user_roles.role_id" => role.id)
end

#role_attributeObject



34
35
36
# File 'lib/roles_data_mapper/strategy/multi/many_roles.rb', line 34

def role_attribute
  strategy_class.roles_attribute_name
end