2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
class RunnerEntity < Grape::Entity
|
|
|
|
include RequestAwareEntity
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expose :id, :description, :short_sha
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
expose :edit_path, if: -> (*) { can_edit_runner? } do |runner|
|
2017-09-10 17:25:29 +05:30
|
|
|
edit_project_runner_path(project, runner)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
alias_method :runner, :object
|
|
|
|
|
|
|
|
def project
|
|
|
|
request.project
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
|
|
|
|
def can_edit_runner?
|
|
|
|
can?(request.current_user, :update_runner, runner) && runner.project_type?
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|