BigW Consortium Gitlab

deploy_key_entity.rb 558 Bytes
Newer Older
1 2 3 4 5 6
class DeployKeyEntity < Grape::Entity
  expose :id
  expose :user_id
  expose :title
  expose :fingerprint
  expose :can_push
7 8
  expose :destroyed_when_orphaned?, as: :destroyed_when_orphaned
  expose :almost_orphaned?, as: :almost_orphaned
9 10 11
  expose :created_at
  expose :updated_at
  expose :projects, using: ProjectEntity do |deploy_key|
12
    deploy_key.projects.without_deleted.select { |project| options[:user].can?(:read_project, project) }
13
  end
14 15 16 17 18 19 20
  expose :can_edit

  private

  def can_edit
    options[:user].can?(:update_deploy_key, object)
  end
21
end