Module: RoleStrategy::Mongoid::OneRole::ClassMethods

Defined in:
lib/roles_mongoid/strategy/single/one_role.rb

Instance Method Summary collapse

Instance Method Details

#in_role(role_name) ⇒ Object



17
18
19
# File 'lib/roles_mongoid/strategy/single/one_role.rb', line 17

def in_role(role_name)  
  in_roles(role_name)
end

#in_roles(*role_names) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/roles_mongoid/strategy/single/one_role.rb', line 21

def in_roles(*role_names)
  begin
    role_ids = Role.where(:name.in => role_names.to_strings).to_a.map(&:user_id)
    where(:_id.in => role_ids)
  rescue 
    return []
  end
end

#role_attributeObject



13
14
15
# File 'lib/roles_mongoid/strategy/single/one_role.rb', line 13

def role_attribute
  strategy_class.roles_attribute_name.to_sym
end