Module: RoleStrategy::MongoMapper::RoleStrings::Implementation
Instance Method Summary
collapse
#add_roles, #remove_roles, #roles, #roles=, #roles_list
Instance Method Details
#new_roles(*roles) ⇒ Object
34
35
36
|
# File 'lib/roles_mongo_mapper/strategy/multi/role_strings.rb', line 34
def new_roles *roles
::Set.new select_valid_roles(roles)
end
|
#present_roles(roles_names) ⇒ Object
46
47
48
|
# File 'lib/roles_mongo_mapper/strategy/multi/role_strings.rb', line 46
def present_roles roles_names
roles_names.to_a
end
|
#select_valid_roles(*roles) ⇒ Object
38
39
40
|
# File 'lib/roles_mongo_mapper/strategy/multi/role_strings.rb', line 38
def select_valid_roles *roles
roles.flat_uniq.select{|role| valid_role? role }.map(&:to_sym)
end
|
#set_empty_roles ⇒ Object
42
43
44
|
# File 'lib/roles_mongo_mapper/strategy/multi/role_strings.rb', line 42
def set_empty_roles
self.send("#{role_attribute}=", [])
end
|