2018-07-19 14:43:13 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-21 08:51:53 -05:00
|
|
|
class BuildActionEntity < Grape::Entity
|
2016-11-10 09:32:23 -05:00
|
|
|
include RequestAwareEntity
|
|
|
|
|
|
|
|
expose :name do |build|
|
2017-01-01 09:04:30 -05:00
|
|
|
build.name
|
2016-11-10 09:32:23 -05:00
|
|
|
end
|
|
|
|
|
2016-12-21 08:47:20 -05:00
|
|
|
expose :path do |build|
|
2017-06-29 13:06:35 -04:00
|
|
|
play_project_job_path(build.project, build)
|
2016-11-10 09:32:23 -05:00
|
|
|
end
|
2017-03-17 12:25:17 -04:00
|
|
|
|
|
|
|
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
|
2017-04-06 11:16:19 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
alias_method :build, :object
|
|
|
|
|
|
|
|
def playable?
|
2017-05-09 00:15:34 -04:00
|
|
|
build.playable? && can?(request.current_user, :update_build, build)
|
2017-04-06 11:16:19 -04:00
|
|
|
end
|
2018-11-02 07:52:34 -04:00
|
|
|
|
|
|
|
def scheduled?
|
|
|
|
build.scheduled?
|
|
|
|
end
|
2016-11-10 09:32:23 -05:00
|
|
|
end
|