Module: RoleStrategy::Generic::RoleStrings::Implementation
Instance Method Summary
collapse
#add_roles, #remove_roles, #roles_list
Instance Method Details
#new_roles(*roles) ⇒ Object
10
11
12
|
# File 'lib/roles_generic/strategy/multi/role_strings.rb', line 10
def new_roles *roles
::Set.new select_valid_roles(roles)
end
|
#present_roles(roles_names) ⇒ Object
22
23
24
|
# File 'lib/roles_generic/strategy/multi/role_strings.rb', line 22
def present_roles roles_names
roles_names.to_a
end
|
#select_valid_roles(*roles) ⇒ Object
14
15
16
|
# File 'lib/roles_generic/strategy/multi/role_strings.rb', line 14
def select_valid_roles *roles
roles.flat_uniq.select{|role| valid_role? role }.map(&:to_sym)
end
|
#set_empty_roles ⇒ Object
18
19
20
|
# File 'lib/roles_generic/strategy/multi/role_strings.rb', line 18
def set_empty_roles
self.send("#{role_attribute}=", [])
end
|