Module: RoleStrategy::DataMapper::ManyRoles::Implementation
Instance Method Summary
collapse
#add_roles, #remove_roles, #roles, #roles_list
Instance Method Details
#new_roles(*role_names) ⇒ Object
62
63
64
|
# File 'lib/roles_data_mapper/strategy/multi/many_roles.rb', line 62
def new_roles *role_names
role_class.find_roles( role_names)
end
|
#present_roles(roles_names) ⇒ Object
66
67
68
|
# File 'lib/roles_data_mapper/strategy/multi/many_roles.rb', line 66
def present_roles roles_names
roles_names.to_a.map{|role| role.name.to_s.to_sym}
end
|
#roles=(*role_names) ⇒ Object
53
54
55
56
57
58
59
60
|
# File 'lib/roles_data_mapper/strategy/multi/many_roles.rb', line 53
def roles=(*role_names)
role_names = role_names.flat_uniq
role_names = (role_names)
return nil if role_names.empty?
valids = role_class.find_roles(role_names).to_a
vrs = select_valid_roles role_names
set_roles(vrs)
end
|
#set_empty_roles ⇒ Object
70
71
72
|
# File 'lib/roles_data_mapper/strategy/multi/many_roles.rb', line 70
def set_empty_roles
self.send("#{role_attribute}=", [])
end
|