Class: CommitWithPipeline
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- CommitWithPipeline
- Includes:
- Presentable
- Defined in:
- app/models/commit_with_pipeline.rb
Instance Method Summary collapse
-
#initialize(commit) ⇒ CommitWithPipeline
constructor
A new instance of CommitWithPipeline.
- #last_pipeline ⇒ Object
- #latest_pipeline(ref = nil) ⇒ Object
- #latest_pipeline_for_project(ref, pipeline_project) ⇒ Object
- #pipelines ⇒ Object
- #set_latest_pipeline_for_ref(ref, pipeline) ⇒ Object
- #status(ref = nil) ⇒ Object
Methods included from Presentable
Constructor Details
#initialize(commit) ⇒ CommitWithPipeline
Returns a new instance of CommitWithPipeline.
6 7 8 9 |
# File 'app/models/commit_with_pipeline.rb', line 6 def initialize(commit) @latest_pipelines = {} super(commit) end |
Instance Method Details
#last_pipeline ⇒ Object
15 16 17 18 19 |
# File 'app/models/commit_with_pipeline.rb', line 15 def last_pipeline strong_memoize(:last_pipeline) do pipelines.last end end |
#latest_pipeline(ref = nil) ⇒ Object
21 22 23 24 25 |
# File 'app/models/commit_with_pipeline.rb', line 21 def latest_pipeline(ref = nil) @latest_pipelines.fetch(ref) do |ref| @latest_pipelines[ref] = latest_pipeline_for_project(ref, project) end end |
#latest_pipeline_for_project(ref, pipeline_project) ⇒ Object
27 28 29 |
# File 'app/models/commit_with_pipeline.rb', line 27 def latest_pipeline_for_project(ref, pipeline_project) pipeline_project.ci_pipelines.latest_pipeline_per_commit(id, ref)[id] end |
#pipelines ⇒ Object
11 12 13 |
# File 'app/models/commit_with_pipeline.rb', line 11 def pipelines project.ci_pipelines.where(sha: sha) end |
#set_latest_pipeline_for_ref(ref, pipeline) ⇒ Object
31 32 33 |
# File 'app/models/commit_with_pipeline.rb', line 31 def set_latest_pipeline_for_ref(ref, pipeline) @latest_pipelines[ref] = pipeline end |
#status(ref = nil) ⇒ Object
35 36 37 |
# File 'app/models/commit_with_pipeline.rb', line 35 def status(ref = nil) latest_pipeline(ref)&.status end |