2016-11-03 07:54:10 -04:00
|
|
|
class BuildEntity < Grape::Entity
|
|
|
|
include RequestAwareEntity
|
|
|
|
|
|
|
|
expose :id
|
|
|
|
expose :name
|
|
|
|
|
2016-11-17 10:08:05 -05:00
|
|
|
expose :build_path do |build|
|
|
|
|
path_to(:namespace_project_build, build)
|
2016-11-03 07:54:10 -04:00
|
|
|
end
|
|
|
|
|
2016-11-17 10:08:05 -05:00
|
|
|
expose :retry_path do |build|
|
|
|
|
path_to(:retry_namespace_project_build, build)
|
2016-11-03 08:35:57 -04:00
|
|
|
end
|
|
|
|
|
2017-02-28 10:48:39 -05:00
|
|
|
expose :play_path, if: ->(build, _) { build.playable? } do |build|
|
2016-11-17 10:08:05 -05:00
|
|
|
path_to(:play_namespace_project_build, build)
|
2016-11-03 08:35:57 -04:00
|
|
|
end
|
|
|
|
|
2016-11-29 05:57:16 -05:00
|
|
|
expose :created_at
|
|
|
|
expose :updated_at
|
|
|
|
|
2016-11-03 08:35:57 -04:00
|
|
|
private
|
|
|
|
|
2016-11-17 10:08:05 -05:00
|
|
|
def path_to(route, build)
|
|
|
|
send("#{route}_path", build.project.namespace, build.project, build)
|
2016-11-03 07:54:10 -04:00
|
|
|
end
|
|
|
|
end
|