gitlab-org--gitlab-foss/app/serializers/build_entity.rb

36 lines
753 B
Ruby
Raw Normal View History

class BuildEntity < Grape::Entity
include RequestAwareEntity
expose :id
expose :name
expose :build_path do |build|
path_to(:namespace_project_build, build)
end
expose :retry_path do |build|
path_to(:retry_namespace_project_build, build)
end
2017-02-28 10:48:39 -05:00
expose :play_path, if: ->(build, _) { build.playable? } do |build|
path_to(:play_namespace_project_build, build)
end
expose :playable?, as: :playable
expose :created_at
expose :updated_at
2017-03-10 10:16:48 -05:00
expose :detailed_status, as: :status, with: StatusEntity
private
alias_method :build, :object
def path_to(route, build)
send("#{route}_path", build.project.namespace, build.project, build)
end
def detailed_status
build.detailed_status(request.user)
end
end