Class: Organizations::GroupsFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/organizations/groups_finder.rb

Instance Method Summary collapse

Constructor Details

#initialize(organization:, current_user:, params: {}) ⇒ GroupsFinder

Returns a new instance of GroupsFinder.

Parameters:

  • organization (Organizations::Organization)
  • current_user (User)
  • params ({ sort: { field: [String], direction: [String] }, search: [String] }) (defaults to: {})


11
12
13
14
15
# File 'app/finders/organizations/groups_finder.rb', line 11

def initialize(organization:, current_user:, params: {})
  @organization = organization
  @current_user = current_user
  @params = params
end

Instance Method Details

#executeObject



17
18
19
20
21
22
23
# File 'app/finders/organizations/groups_finder.rb', line 17

def execute
  return Group.none if organization.nil? || !authorized?

  filter_groups(all_accessible_groups)
    .then { |groups| sort(groups) }
    .then(&:with_route)
end