Module: RoleStrategy::Mongoid::EmbedManyRoles::ClassMethods

Defined in:
lib/roles_mongoid/strategy/multi/embed_many_roles.rb

Instance Method Summary collapse

Instance Method Details

#in_any_role(*role_names) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/roles_mongoid/strategy/multi/embed_many_roles.rb', line 23

def in_any_role(*role_names)
  begin
    any_in("many_roles.name" => role_names)
  rescue
    return []
  end
end

#in_role(role_name) ⇒ Object



19
20
21
# File 'lib/roles_mongoid/strategy/multi/embed_many_roles.rb', line 19

def in_role(role_name)
  in_any_role(role_name)
end

#role_attributeObject



15
16
17
# File 'lib/roles_mongoid/strategy/multi/embed_many_roles.rb', line 15

def role_attribute
  "#{strategy_class.roles_attribute_name.to_s.singularize}_ids".to_sym
end