BigW Consortium Gitlab

build_entity.rb 513 Bytes
Newer Older
1 2 3 4 5 6
class BuildEntity < Grape::Entity
  include RequestAwareEntity

  expose :id
  expose :name

7 8
  expose :build_path do |build|
    path_to(:namespace_project_build, build)
9 10
  end

11 12
  expose :retry_path do |build|
    path_to(:retry_namespace_project_build, build)
13 14
  end

15 16
  expose :play_path, if: ->(build, _) { build.manual? } do |build|
    path_to(:play_namespace_project_build, build)
17 18 19 20
  end

  private

21 22
  def path_to(route, build)
    send("#{route}_path", build.project.namespace, build.project, build)
23 24
  end
end