summaryrefslogtreecommitdiff
path: root/app/serializers/runner_entity.rb
blob: 97e5b336a35cadff75f8091cb3bc14a0d1bfb294 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

class RunnerEntity < Grape::Entity
  include RequestAwareEntity

  expose :id, :description

  expose :edit_path, if: -> (*) { can_edit_runner? } do |runner|
    edit_project_runner_path(project, runner)
  end

  private

  alias_method :runner, :object

  def project
    request.project
  end

  def can_edit_runner?
    can?(request.current_user, :update_runner, runner) && runner.project_type?
  end
end