Class: Key

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
AfterCommitQueue, Sortable
Defined in:
app/models/key.rb

Direct Known Subclasses

DeployKey

Instance Method Summary collapse

Instance Method Details

#add_to_shellObject


57
58
59
60
61
62
63
# File 'app/models/key.rb', line 57

def add_to_shell
  GitlabShellWorker.perform_async(
    :add_key,
    shell_id,
    key
  )
end

#notify_userObject


65
66
67
# File 'app/models/key.rb', line 65

def notify_user
  run_after_commit { NotificationService.new.new_key(self) }
end

#post_create_hookObject


69
70
71
# File 'app/models/key.rb', line 69

def post_create_hook
  SystemHooksService.new.execute_hooks_for(self, :create)
end

#post_destroy_hookObject


81
82
83
# File 'app/models/key.rb', line 81

def post_destroy_hook
  SystemHooksService.new.execute_hooks_for(self, :destroy)
end

#projectsObject

projects that has this key


49
50
51
# File 'app/models/key.rb', line 49

def projects
  user.authorized_projects
end

#publishable_keyObject


43
44
45
46
# File 'app/models/key.rb', line 43

def publishable_key
  #Removes anything beyond the keytype and key itself
  self.key.split[0..1].join(' ')
end

#remove_from_shellObject


73
74
75
76
77
78
79
# File 'app/models/key.rb', line 73

def remove_from_shell
  GitlabShellWorker.perform_async(
    :remove_key,
    shell_id,
    key,
  )
end

#shell_idObject


53
54
55
# File 'app/models/key.rb', line 53

def shell_id
  "key-#{id}"
end

#strip_white_spaceObject


39
40
41
# File 'app/models/key.rb', line 39

def strip_white_space
  self.key = key.strip unless key.blank?
end