Class: ProtectedBranchesFinder

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

Overview

ProtectedBranchesFinder

Used to filter protected branches by set of params

Arguments:

project - which project to scope to
params:
  search: string

Constant Summary collapse

LIMIT =
100

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_or_group, params = {}) ⇒ ProtectedBranchesFinder

Returns a new instance of ProtectedBranchesFinder.



16
17
18
19
# File 'app/finders/protected_branches_finder.rb', line 16

def initialize(project_or_group, params = {})
  @project_or_group = project_or_group
  @params = params
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



14
15
16
# File 'app/finders/protected_branches_finder.rb', line 14

def params
  @params
end

#project_or_groupObject

Returns the value of attribute project_or_group.



14
15
16
# File 'app/finders/protected_branches_finder.rb', line 14

def project_or_group
  @project_or_group
end

Instance Method Details

#executeObject



21
22
23
24
25
26
27
28
29
30
# File 'app/finders/protected_branches_finder.rb', line 21

def execute
  protected_branches = if project_or_group.is_a?(Group)
                         project_or_group.protected_branches
                       else
                         project_or_group.all_protected_branches
                       end

  protected_branches = protected_branches.limit(LIMIT)
  by_name(protected_branches)
end