Module: TroleGroups::Api::Write
- Defined in:
- lib/trole_groups/api/write.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#add_rolegroup(rolegroup_name) ⇒ true, ...
Add a single new rolegroup to the rolegroups of the subject.
-
#add_rolegroups(*new_rolegroups) ⇒ true, ...
Adds a set of new rolegroups to the rolegroups of the subject.
-
#clear_rolegroups! ⇒ true, ...
Clears all the rolegroups of the subject.
-
#remove_rolegroup(rolegroup_name) ⇒ Object
Remove a single rolegroup from the rolegroups of the subject.
-
#remove_rolegroups(*the_rolegroups) ⇒ Object
Removes a set of new rolegroups to the rolegroups of the subject (see #add_rolegroups).
-
#set_rolegroups(*rolegroups) ⇒ true, ...
Sets new rolegroups for the subject.
Instance Method Details
#add_rolegroup(rolegroup_name) ⇒ true, ...
Add a single new rolegroup to the rolegroups of the subject
6 7 8 9 |
# File 'lib/trole_groups/api/write.rb', line 6 def add_rolegroup rolegroup_name raise ArgumentError, "Take a single rolegroup name, was: #{rolegroup_name}" if !rolegroup_name || !rolegroup_name.kind_of_label? add_rolegroups rolegroup_name end |
#add_rolegroups(*new_rolegroups) ⇒ true, ...
Adds a set of new rolegroups to the rolegroups of the subject
22 23 24 |
# File 'lib/trole_groups/api/write.rb', line 22 def add_rolegroups *new_rolegroups group_store.set_rolegroups (rolegroup_list | new_rolegroups.to_symbols_uniq) # Set Union (joined set) end |
#clear_rolegroups! ⇒ true, ...
Clears all the rolegroups of the subject
43 44 45 |
# File 'lib/trole_groups/api/write.rb', line 43 def clear_rolegroups! group_store.clear! end |
#remove_rolegroup(rolegroup_name) ⇒ Object
Remove a single rolegroup from the rolegroups of the subject
14 15 16 17 |
# File 'lib/trole_groups/api/write.rb', line 14 def remove_rolegroup rolegroup_name raise ArgumentError, "Take a single rolegroup name, was: #{rolegroup_name}" if !rolegroup_name || !rolegroup_name.kind_of_label? remove_rolegroups rolegroup_name end |
#remove_rolegroups(*the_rolegroups) ⇒ Object
Removes a set of new rolegroups to the rolegroups of the subject (see #add_rolegroups)
28 29 30 |
# File 'lib/trole_groups/api/write.rb', line 28 def remove_rolegroups *the_rolegroups group_store.set_rolegroups (rolegroup_list - the_rolegroups.to_symbols_uniq) end |
#set_rolegroups(*rolegroups) ⇒ true, ...
Sets new rolegroups for the subject
35 36 37 38 39 |
# File 'lib/trole_groups/api/write.rb', line 35 def set_rolegroups *rolegroups rolegroups_to_set = make_valid_rolegroups(*rolegroups).flat_uniq return false if !rolegroups_to_set || rolegroups_to_set.empty? group_store.set_rolegroups(rolegroups_to_set) end |