Class: PlanMyStuff::Label
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- PlanMyStuff::Label
- Defined in:
- lib/plan_my_stuff/label.rb
Overview
Wraps a GitHub label with a reference to its parent issue. Class methods provide the public API for add/remove operations.
Instance Attribute Summary collapse
-
#issue ⇒ PlanMyStuff::Issue
Parent issue.
-
#name ⇒ String
Label name.
Class Method Summary collapse
-
.add(issue:, labels:) ⇒ Array<PlanMyStuff::Label>
Adds labels to a GitHub issue.
-
.remove(issue:, labels:) ⇒ Array<Array<PlanMyStuff::Label>>
Removes labels from a GitHub issue.
Methods inherited from ApplicationRecord
#initialize, #new_record?, #persisted?
Constructor Details
This class inherits a constructor from PlanMyStuff::ApplicationRecord
Instance Attribute Details
#issue ⇒ PlanMyStuff::Issue
Returns parent issue.
10 11 12 |
# File 'lib/plan_my_stuff/label.rb', line 10 def issue @issue end |
#name ⇒ String
Returns label name.
8 9 10 |
# File 'lib/plan_my_stuff/label.rb', line 8 def name @name end |
Class Method Details
.add(issue:, labels:) ⇒ Array<PlanMyStuff::Label>
Adds labels to a GitHub issue.
20 21 22 23 24 25 26 |
# File 'lib/plan_my_stuff/label.rb', line 20 def add(issue:, labels:) result = PlanMyStuff.client.rest( :add_labels_to_an_issue, issue.repo, issue.number, labels, ) result.map { |gh_label| build(gh_label, issue: issue) } end |
.remove(issue:, labels:) ⇒ Array<Array<PlanMyStuff::Label>>
Removes labels from a GitHub issue.
35 36 37 38 39 40 |
# File 'lib/plan_my_stuff/label.rb', line 35 def remove(issue:, labels:) Array.wrap(labels).map do |label| result = PlanMyStuff.client.rest(:remove_label, issue.repo, issue.number, label) result.map { |gh_label| build(gh_label, issue: issue) } end end |