Class: Projects::BranchRule
- Inherits:
-
Object
- Object
- Projects::BranchRule
- Extended by:
- Forwardable
- Includes:
- GlobalID::Identification
- Defined in:
- app/models/projects/branch_rule.rb
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#protected_branch ⇒ Object
(also: #branch_protection)
readonly
Returns the value of attribute protected_branch.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(project, protected_branch) ⇒ BranchRule
constructor
A new instance of BranchRule.
- #matching_branches_count ⇒ Object
- #protected? ⇒ Boolean
Constructor Details
#initialize(project, protected_branch) ⇒ BranchRule
Returns a new instance of BranchRule.
21 22 23 24 |
# File 'app/models/projects/branch_rule.rb', line 21 def initialize(project, protected_branch) @project = project @protected_branch = protected_branch end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
8 9 10 |
# File 'app/models/projects/branch_rule.rb', line 8 def project @project end |
#protected_branch ⇒ Object (readonly) Also known as: branch_protection
Returns the value of attribute protected_branch.
8 9 10 |
# File 'app/models/projects/branch_rule.rb', line 8 def protected_branch @protected_branch end |
Class Method Details
.find(id) ⇒ Object
13 14 15 16 17 18 19 |
# File 'app/models/projects/branch_rule.rb', line 13 def self.find(id) protected_branch = ProtectedBranch.find(id) new(protected_branch.project, protected_branch) rescue ActiveRecord::RecordNotFound raise ActiveRecord::RecordNotFound, "Couldn't find Projects::BranchRule with 'id'=#{id}" end |
Instance Method Details
#matching_branches_count ⇒ Object
30 31 32 33 34 |
# File 'app/models/projects/branch_rule.rb', line 30 def matching_branches_count branch_names = project.repository.branch_names matching_branches = protected_branch.matching(branch_names) matching_branches.count end |
#protected? ⇒ Boolean
26 27 28 |
# File 'app/models/projects/branch_rule.rb', line 26 def protected? true end |