Module: RoleStrategy::DataMapper::OneRole::Implementation
Instance Method Summary
collapse
#add_roles, #roles_list
#get_role, #get_roles, #select_valid_roles, #set_role
Instance Method Details
#new_role(role) ⇒ Object
45
46
47
|
# File 'lib/roles_data_mapper/strategy/single/one_role.rb', line 45
def new_role role
role_class.find_role( role)
end
|
#new_roles(*roles) ⇒ Object
49
50
51
|
# File 'lib/roles_data_mapper/strategy/single/one_role.rb', line 49
def new_roles *roles
new_role roles.flatten.first
end
|
#present_roles(*roles) ⇒ Object
59
60
61
|
# File 'lib/roles_data_mapper/strategy/single/one_role.rb', line 59
def present_roles *roles
roles.map{|role| role}
end
|
#remove_roles(*role_names) ⇒ Object
53
54
55
56
57
|
# File 'lib/roles_data_mapper/strategy/single/one_role.rb', line 53
def remove_roles *role_names
roles = role_names.flat_uniq
set_empty_role if roles_diff(roles).empty?
true
end
|
#set_empty_role ⇒ Object
63
64
65
|
# File 'lib/roles_data_mapper/strategy/single/one_role.rb', line 63
def set_empty_role
self.send("#{role_attribute}=", nil)
end
|