summaryrefslogtreecommitdiff
path: root/app/serializers/build_artifact_entity.rb
blob: cb55c98f7c6db042c27de703d6296c784b2b1934 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class BuildArtifactEntity < Grape::Entity
  include RequestAwareEntity

  expose :name do |job|
    job.name
  end

  expose :artifacts_expired?, as: :expired
  expose :artifacts_expire_at, as: :expire_at

  expose :path do |job|
    download_namespace_project_job_artifacts_path(
      project.namespace,
      project,
      job)
  end

  expose :keep_path, if: -> (*) { job.has_expiring_artifacts? } do |job|
    keep_namespace_project_job_artifacts_path(
      project.namespace,
      project,
      job)
  end

  expose :browse_path do |job|
    browse_namespace_project_job_artifacts_path(
      project.namespace,
      project,
      job)
  end

  private

  alias_method :job, :object

  def project
    job.project
  end
end