Class: Namespaces::ProjectsFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/namespaces/projects_finder.rb

Instance Method Summary collapse

Constructor Details

#initialize(namespace: nil, current_user: nil, params: {}) ⇒ ProjectsFinder

Returns a new instance of ProjectsFinder.


18
19
20
21
22
# File 'app/finders/namespaces/projects_finder.rb', line 18

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

Instance Method Details

#executeObject


24
25
26
27
28
29
30
31
32
33
34
# File 'app/finders/namespaces/projects_finder.rb', line 24

def execute
  return Project.none if namespace.nil?

  collection = if params[:include_subgroups].present?
                 namespace.all_projects.with_route
               else
                 namespace.projects.with_route
               end

  filter_projects(collection)
end