summaryrefslogtreecommitdiff
path: root/app/serializers/build_entity.rb
blob: 3d9ac66de0e5a1d5d96dace4acebea48030e27c9 (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
class BuildEntity < Grape::Entity
  include RequestAwareEntity

  expose :id
  expose :name

  expose :build_url do |build|
    url_to(:namespace_project_build, build)
  end

  expose :retry_url do |build|
    url_to(:retry_namespace_project_build, build)
  end

  expose :play_url, if: ->(build, _) { build.manual? } do |build|
    url_to(:play_namespace_project_build, build)
  end

  private

  def url_to(route, build)
    send("#{route}_url", build.project.namespace, build.project, build)
  end
end