Module: RoleStrategy::MongoMapper::EmbedOneRole::ClassMethods
- Defined in:
- lib/roles_mongo_mapper/strategy/single/embed_one_role.rb
Instance Method Summary collapse
- #in_any_role(*role_names) ⇒ Object
- #in_role(role_name) ⇒ Object
- #role_attribute ⇒ Object
- #role_id_attribute ⇒ Object
Instance Method Details
#in_any_role(*role_names) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/roles_mongo_mapper/strategy/single/embed_one_role.rb', line 28 def in_any_role(*role_names) begin role_ids = Role.find_roles(role_names).map(&:id) all("#{role_attribute}._id" => role_ids) rescue return [] end end |
#in_role(role_name) ⇒ Object
24 25 26 |
# File 'lib/roles_mongo_mapper/strategy/single/embed_one_role.rb', line 24 def in_role(role_name) in_any_role(role_name) end |
#role_attribute ⇒ Object
16 17 18 |
# File 'lib/roles_mongo_mapper/strategy/single/embed_one_role.rb', line 16 def role_attribute strategy_class.roles_attribute_name.to_sym end |
#role_id_attribute ⇒ Object
20 21 22 |
# File 'lib/roles_mongo_mapper/strategy/single/embed_one_role.rb', line 20 def role_id_attribute "#{role_attribute}_id".to_sym end |