Create ClustersFinder

This commit is contained in:
Matija Čupić 2017-11-27 13:48:46 +01:00
parent 52bc826196
commit 0af5ae90cb
No known key found for this signature in database
GPG Key ID: 4BAF84FFACD2E5DE
1 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,19 @@
class ClustersFinder
def initialize(project, user, scope)
@project = project
@user = user
@scope = scope
end
def execute
clusters = case @scope
when :all
project.clusters
when :disabled
project.clusters.enabled
when :enabled
project.clusters.disabled
end
clusters.map { |cluster| cluster.present(current_user: @user) }
end
end