Module: Roles::DataMapper::Strategy::Shared
- Included in:
- Single
- Defined in:
- lib/roles_data_mapper/strategy/shared.rb
Instance Method Summary collapse
- #get_role ⇒ Object
- #get_roles ⇒ Object
- #select_valid_roles(*roles) ⇒ Object
- #set_role(role) ⇒ Object (also: #set_roles)
Instance Method Details
#get_role ⇒ Object
11 12 13 14 |
# File 'lib/roles_data_mapper/strategy/shared.rb', line 11 def get_role r = self.send(role_attribute) # respond_to?(:present_role) ? present_role(r) : r end |
#get_roles ⇒ Object
16 17 18 |
# File 'lib/roles_data_mapper/strategy/shared.rb', line 16 def get_roles r = self.send(role_attribute) end |
#select_valid_roles(*roles) ⇒ Object
20 21 22 23 |
# File 'lib/roles_data_mapper/strategy/shared.rb', line 20 def select_valid_roles *roles roles.flat_uniq.select{|role| valid_role? role } has_role_class? ? role_class.find_roles(roles).to_a.flat_uniq : roles.flat_uniq end |
#set_role(role) ⇒ Object Also known as: set_roles
4 5 6 7 8 |
# File 'lib/roles_data_mapper/strategy/shared.rb', line 4 def set_role role vr = new_role(role) self.send("#{role_attribute}=", vr) # update_attributes(role_attribute => vr) end |