2016-11-03 07:54:10 -04:00
|
|
|
class BuildEntity < Grape::Entity
|
|
|
|
include RequestAwareEntity
|
|
|
|
|
|
|
|
expose :id
|
|
|
|
expose :name
|
|
|
|
|
|
|
|
expose :build_url do |build|
|
2016-11-03 08:35:57 -04:00
|
|
|
url_to(:namespace_project_build, build)
|
2016-11-03 07:54:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
expose :retry_url do |build|
|
2016-11-03 08:35:57 -04:00
|
|
|
url_to(:retry_namespace_project_build, build)
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :play_url, if: ->(build, _) { build.manual? } do |build|
|
2016-11-03 10:13:57 -04:00
|
|
|
url_to(:play_namespace_project_build, build)
|
2016-11-03 08:35:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def url_to(route, build)
|
2016-11-04 10:00:39 -04:00
|
|
|
send("#{route}_url", build.project.namespace, build.project, build)
|
2016-11-03 07:54:10 -04:00
|
|
|
end
|
|
|
|
end
|