debian-mirror-gitlab/app/serializers/build_action_entity.rb

34 lines
674 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
class BuildActionEntity < Grape::Entity
include RequestAwareEntity
expose :name do |build|
build.name
end
expose :path do |build|
2017-09-10 17:25:29 +05:30
play_project_job_path(build.project, build)
2017-08-17 22:00:37 +05:30
end
expose :playable?, as: :playable
2018-12-13 13:39:08 +05:30
expose :scheduled?, as: :scheduled
expose :scheduled_at, if: -> (*) { scheduled? }
2018-12-05 23:21:45 +05:30
expose :unschedule_path, if: -> (build) { build.scheduled? } do |build|
unschedule_project_job_path(build.project, build)
end
2017-08-17 22:00:37 +05:30
private
alias_method :build, :object
def playable?
build.playable? && can?(request.current_user, :update_build, build)
end
2018-12-13 13:39:08 +05:30
def scheduled?
build.scheduled?
end
2017-08-17 22:00:37 +05:30
end