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
|
|
|
|
|
2017-03-17 12:25:17 -04:00
|
|
|
expose :playable?, as: :playable
|
2016-11-29 05:57:16 -05:00
|
|
|
expose :created_at
|
|
|
|
expose :updated_at
|
2017-03-10 10:16:48 -05:00
|
|
|
expose :detailed_status, as: :status, with: StatusEntity
|
2016-11-29 05:57:16 -05:00
|
|
|
|
2016-11-03 08:35:57 -04:00
|
|
|
private
|
|
|
|
|
2017-03-03 01:59:25 -05:00
|
|
|
alias_method :build, :object
|
|
|
|
|
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
|
2017-03-03 01:59:25 -05:00
|
|
|
|
|
|
|
def detailed_status
|
|
|
|
build.detailed_status(request.user)
|
|
|
|
end
|
2016-11-03 07:54:10 -04:00
|
|
|
end
|