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