Class: GroupsFinder
- Inherits:
-
UnionFinder
- Object
- UnionFinder
- GroupsFinder
- Includes:
- CustomAttributesFilter
- Defined in:
- app/finders/groups_finder.rb
Overview
GroupsFinder
Used to filter Groups by a set of params
Arguments:
current_user - which user is requesting groups
params:
owned: boolean
parent: Group
all_available: boolean (defaults to true)
min_access_level: integer
exclude_group_ids: array of integers
Users with full private access can see all groups. The `owned` and `parent` params can be used to restrict the groups that are returned.
Anonymous users will never return any `owned` groups. They will return all public groups instead, even if `all_available` is set to false.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(current_user = nil, params = {}) ⇒ GroupsFinder
constructor
A new instance of GroupsFinder.
Methods included from CustomAttributesFilter
Methods inherited from UnionFinder
Constructor Details
#initialize(current_user = nil, params = {}) ⇒ GroupsFinder
Returns a new instance of GroupsFinder.
24 25 26 27 |
# File 'app/finders/groups_finder.rb', line 24 def initialize(current_user = nil, params = {}) @current_user = current_user @params = params end |
Instance Method Details
#execute ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/finders/groups_finder.rb', line 29 def execute items = all_groups.map do |item| item = by_parent(item) item = by_custom_attributes(item) item = exclude_group_ids(item) item end find_union(items, Group).with_route.order_id_desc end |