Class: GroupDeployKey

Inherits:
Key show all
Defined in:
app/models/group_deploy_key.rb

Constant Summary

Constants included from Expirable

Expirable::DAYS_TO_EXPIRE

Instance Method Summary collapse

Methods inherited from Key

#add_to_authorized_keys, #can_delete?, #key=, #post_create_hook, #post_destroy_hook, #projects, #public_key, #publishable_key, #refresh_user_cache, regular_keys, #remove_from_authorized_keys, #shell_id, #update_last_used_at

Methods included from Expirable

#expired?, #expires?, #expires_soon?

Methods included from AfterCommitQueue

#run_after_commit, #run_after_commit_or_now

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, where_exists, with_fast_statement_timeout, without_order

Instance Method Details

#can_be_edited_for?(user, group) ⇒ Boolean

Returns:

  • (Boolean)

23
24
25
26
27
28
29
30
# File 'app/models/group_deploy_key.rb', line 23

def can_be_edited_for?(user, group)
  Ability.allowed?(user, :update_group_deploy_key, self) ||
    Ability.allowed?(
      user,
      :update_group_deploy_key_for_group,
      group_deploy_keys_group_for(group)
    )
end

#group_deploy_keys_group_for(group) ⇒ Object


19
20
21
# File 'app/models/group_deploy_key.rb', line 19

def group_deploy_keys_group_for(group)
  group_deploy_keys_groups.find_by(group: group)
end

#group_deploy_keys_groups_for_user(user) ⇒ Object


32
33
34
35
36
# File 'app/models/group_deploy_key.rb', line 32

def group_deploy_keys_groups_for_user(user)
  group_deploy_keys_groups.select do |group_deploy_keys_group|
    Ability.allowed?(user, :read_group, group_deploy_keys_group.group)
  end
end

#typeObject


15
16
17
# File 'app/models/group_deploy_key.rb', line 15

def type
  'DeployKey'
end