Class: Autocomplete::DeployKeysWithWriteAccessFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/autocomplete/deploy_keys_with_write_access_finder.rb

Overview

Finder for retrieving deploy keys to use for autocomplete data sources.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_user, project) ⇒ DeployKeysWithWriteAccessFinder

Returns a new instance of DeployKeysWithWriteAccessFinder.



8
9
10
11
# File 'app/finders/autocomplete/deploy_keys_with_write_access_finder.rb', line 8

def initialize(current_user, project)
  @current_user = current_user
  @project = project
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



6
7
8
# File 'app/finders/autocomplete/deploy_keys_with_write_access_finder.rb', line 6

def current_user
  @current_user
end

#projectObject (readonly)

Returns the value of attribute project.



6
7
8
# File 'app/finders/autocomplete/deploy_keys_with_write_access_finder.rb', line 6

def project
  @project
end

Instance Method Details

#executeObject



13
14
15
16
17
18
19
# File 'app/finders/autocomplete/deploy_keys_with_write_access_finder.rb', line 13

def execute
  return DeployKey.none if project.nil?

  raise Gitlab::Access::AccessDeniedError unless current_user.can?(:admin_project, project)

  project.deploy_keys.merge(DeployKeysProject.with_write_access)
end