Class: Groups::UserGroupsFinder
- Defined in:
- app/finders/groups/user_groups_finder.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(current_user, target_user, params = {}) ⇒ UserGroupsFinder
constructor
A new instance of UserGroupsFinder.
Constructor Details
#initialize(current_user, target_user, params = {}) ⇒ UserGroupsFinder
Returns a new instance of UserGroupsFinder.
19 20 21 22 23 |
# File 'app/finders/groups/user_groups_finder.rb', line 19 def initialize(current_user, target_user, params = {}) @current_user = current_user @target_user = target_user @params = params end |
Instance Method Details
#execute ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/finders/groups/user_groups_finder.rb', line 25 def execute return Group.none unless current_user&.can?(:read_user_groups, target_user) return Group.none if target_user.blank? items = items = by_organization(items) # Search will perform an ORDER BY to ensure exact matches are returned first. return by_search(items, exact_matches_first: true) if exact_matches_first_enabled? items = by_search(items) sort(items) end |