Module: TroleGroups::Api::Read
- Defined in:
- lib/trole_groups/api/read.rb
Instance Method Summary collapse
-
#in_any_rolegroup?(*rolegroups) ⇒ Boolean
(also: #has_any_rolegroup?)
union of rolegroups and rolegroups_list is not empty.
-
#in_rolegroup?(rolegroup) ⇒ Boolean
(also: #has_rolegroup?)
any? on rolegroups_list.
-
#in_rolegroups?(*rolegroups) ⇒ Boolean
(also: #has_rolegroups?)
subtraction of role_groups from rolegroups_list is empty.
-
#only_in_rolegroup?(rolegroup) ⇒ Boolean
rolegroup_list has one element which is rolegroup.
-
#role_list ⇒ Object
Ensures that the common API methods always have a common underlying model to work on.
-
#rolegroup_list ⇒ Object
return Set of symbols,where each symbol is a rolegroup name This set should be cached and only invalidated when the user has a change of roles.
- #roles_for(*names) ⇒ Object
- #roles_from_rolegroups ⇒ Object
-
#roles_of(rolegroup) ⇒ Object
return roles of that rolegroup.
Instance Method Details
#in_any_rolegroup?(*rolegroups) ⇒ Boolean Also known as: has_any_rolegroup?
union of rolegroups and rolegroups_list is not empty
29 30 31 |
# File 'lib/trole_groups/api/read.rb', line 29 def in_any_rolegroup? *rolegroups !(rolegroup_list & rolegroups.to_symbols).empty? end |
#in_rolegroup?(rolegroup) ⇒ Boolean Also known as: has_rolegroup?
any? on rolegroups_list
12 13 14 |
# File 'lib/trole_groups/api/read.rb', line 12 def in_rolegroup? rolegroup rolegroup_list.include? rolegroup.to_sym end |
#in_rolegroups?(*rolegroups) ⇒ Boolean Also known as: has_rolegroups?
subtraction of role_groups from rolegroups_list is empty
23 24 25 |
# File 'lib/trole_groups/api/read.rb', line 23 def in_rolegroups? *rolegroups (rolegroups.to_symbols - rolegroup_list).empty? end |
#only_in_rolegroup?(rolegroup) ⇒ Boolean
rolegroup_list has one element which is rolegroup
18 19 20 |
# File 'lib/trole_groups/api/read.rb', line 18 def only_in_rolegroup? rolegroup rolegroup_list.first == rolegroup.to_sym && rolegroup_list.size == 1 end |
#role_list ⇒ Object
This Set should be cached and only invalidated when the user has a change of roles
Ensures that the common API methods always have a common underlying model to work on
50 51 52 53 54 |
# File 'lib/trole_groups/api/read.rb', line 50 def role_list @role_list ||= begin (store.display_roles | group_store.display_roles) end end |
#rolegroup_list ⇒ Object
return Set of symbols,where each symbol is a rolegroup name This set should be cached and only invalidated when the user has a change of roles
41 42 43 44 45 |
# File 'lib/trole_groups/api/read.rb', line 41 def rolegroup_list @rolegroup_list ||= begin group_store.display_rolegroups end end |
#roles_for(*names) ⇒ Object
7 8 9 |
# File 'lib/trole_groups/api/read.rb', line 7 def roles_for *names group_store.display_roles_for *names end |
#roles_from_rolegroups ⇒ Object
3 4 5 |
# File 'lib/trole_groups/api/read.rb', line 3 def roles_from_rolegroups group_store.display_roles end |
#roles_of(rolegroup) ⇒ Object
return roles of that rolegroup
35 36 37 |
# File 'lib/trole_groups/api/read.rb', line 35 def roles_of rolegroup raise "Pending" end |