Module: RoleStrategy::MongoMapper::ManyRoles::ClassMethods
- Defined in:
- lib/roles_mongo_mapper/strategy/multi/many_roles.rb,
lib/roles_mongo_mapper/strategy/multi/embed_many_roles.rb
Instance Method Summary collapse
- #in_any_role(*role_names) ⇒ Object
- #in_role(role_name) ⇒ Object
- #in_roles(*role_names) ⇒ Object
- #role_attribute ⇒ Object
- #role_id_attribute ⇒ Object
Instance Method Details
#in_any_role(*role_names) ⇒ Object
33 34 35 36 |
# File 'lib/roles_mongo_mapper/strategy/multi/many_roles.rb', line 33 def in_any_role(*role_names) role_ids = Role.find_roles(role_names).map{|role| role.id} all(role_id_attribute.in => role_ids) end |
#in_role(role_name) ⇒ Object
28 29 30 31 |
# File 'lib/roles_mongo_mapper/strategy/multi/many_roles.rb', line 28 def in_role(role_name) role = Role.find_role(role_name) res = all(role_id_attribute => role.id) end |
#in_roles(*role_names) ⇒ Object
29 30 31 32 |
# File 'lib/roles_mongo_mapper/strategy/multi/embed_many_roles.rb', line 29 def in_roles(*role_names) role_ids = Role.find_roles(role_names).map{|role| role.id} all(role_id_attribute.in => role_ids) end |
#role_attribute ⇒ Object
20 21 22 |
# File 'lib/roles_mongo_mapper/strategy/multi/many_roles.rb', line 20 def role_attribute strategy_class.roles_attribute_name end |
#role_id_attribute ⇒ Object
24 25 26 |
# File 'lib/roles_mongo_mapper/strategy/multi/many_roles.rb', line 24 def role_id_attribute "#{role_attribute}_ids".to_sym end |