Module: RoleStrategy::DataMapper::OneRole::ClassMethods
- Defined in:
- lib/roles_data_mapper/strategy/single/one_role.rb
Instance Method Summary collapse
- #in_any_role(*roles) ⇒ Object
-
#in_role(role_name) ⇒ Object
def role_attribute strategy_class.roles_attribute_name.to_sym end.
Instance Method Details
#in_any_role(*roles) ⇒ Object
36 37 38 39 |
# File 'lib/roles_data_mapper/strategy/single/one_role.rb', line 36 def in_any_role(*roles) role_ids = Role.all(:name.in => roles.flatten).map{|role| role.id} all(:one_role_id => role_ids) end |
#in_role(role_name) ⇒ Object
def role_attribute
strategy_class.roles_attribute_name.to_sym
end
30 31 32 33 34 |
# File 'lib/roles_data_mapper/strategy/single/one_role.rb', line 30 def in_role(role_name) role = Role.all(:name => role_name).first # puts "in role: #{role.inspect}, id: #{role.id}" all(:one_role_id => role.id) end |