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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
674 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class BuildActionEntity < Grape::Entity
include RequestAwareEntity
expose :name do |build|
build.name
end
expose :path do |build|
play_project_job_path(build.project, build)
end
expose :playable?, as: :playable
2018-11-02 07:52:34 -04:00
expose :scheduled?, as: :scheduled
expose :scheduled_at, if: -> (*) { scheduled? }
2018-10-01 03:09:41 -04:00
expose :unschedule_path, if: -> (build) { build.scheduled? } do |build|
unschedule_project_job_path(build.project, build)
end
private
alias_method :build, :object
def playable?
2017-05-09 00:15:34 -04:00
build.playable? && can?(request.current_user, :update_build, build)
end
2018-11-02 07:52:34 -04:00
def scheduled?
build.scheduled?
end
end