Class: Projects::BranchRule

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
app/models/projects/branch_rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, protected_branch) ⇒ BranchRule

Returns a new instance of BranchRule.



11
12
13
14
# File 'app/models/projects/branch_rule.rb', line 11

def initialize(project, protected_branch)
  @protected_branch = protected_branch
  @project = project
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



7
8
9
# File 'app/models/projects/branch_rule.rb', line 7

def project
  @project
end

#protected_branchObject (readonly)

Returns the value of attribute protected_branch.



7
8
9
# File 'app/models/projects/branch_rule.rb', line 7

def protected_branch
  @protected_branch
end

Instance Method Details

#branch_protectionObject



26
27
28
# File 'app/models/projects/branch_rule.rb', line 26

def branch_protection
  protected_branch
end

#matching_branches_countObject



20
21
22
23
24
# File 'app/models/projects/branch_rule.rb', line 20

def matching_branches_count
  branch_names = project.repository.branch_names
  matching_branches = protected_branch.matching(branch_names)
  matching_branches.count
end

#protected?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'app/models/projects/branch_rule.rb', line 16

def protected?
  true
end