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

25 lines
698 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 DeployKeyEntity < Grape::Entity
expose :id
expose :user_id
expose :title
expose :fingerprint
expose :destroyed_when_orphaned?, as: :destroyed_when_orphaned
expose :almost_orphaned?, as: :almost_orphaned
expose :created_at
expose :updated_at
2018-03-17 18:26:18 +05:30
expose :deploy_keys_projects, using: DeployKeysProjectEntity do |deploy_key|
deploy_key.deploy_keys_projects
.without_project_deleted
.select { |deploy_key_project| Ability.allowed?(options[:user], :read_project, deploy_key_project.project) }
2017-09-10 17:25:29 +05:30
end
expose :can_edit
private
def can_edit
2018-03-17 18:26:18 +05:30
Ability.allowed?(options[:user], :update_deploy_key, object)
2017-08-17 22:00:37 +05:30
end
end