Class: Gitlab::UserAccessSnippet

Inherits:
UserAccess show all
Extended by:
Cache::RequestCache, Gitlab::Utils::Override
Defined in:
lib/gitlab/user_access_snippet.rb

Instance Attribute Summary collapse

Attributes included from Cache::RequestCache

#request_cache_key_block

Attributes inherited from UserAccess

#container, #push_ability, #user

Instance Method Summary collapse

Methods included from Gitlab::Utils::Override

extended, extensions, included, method_added, override, prepended, queue_verification, verify!

Methods included from Cache::RequestCache

extended, request_cache, request_cache_key

Methods inherited from UserAccess

#allowed?, #can_push_for_ref?, #can_update_branch?, #cannot_do_action?

Constructor Details

#initialize(user, snippet: nil) ⇒ UserAccessSnippet

Returns a new instance of UserAccessSnippet.



16
17
18
19
# File 'lib/gitlab/user_access_snippet.rb', line 16

def initialize(user, snippet: nil)
  super(user, container: snippet)
  @project = snippet&.project
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



49
50
51
# File 'lib/gitlab/user_access_snippet.rb', line 49

def project
  @project
end

Instance Method Details

#can_create_tag?(ref) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/gitlab/user_access_snippet.rb', line 30

def can_create_tag?(ref)
  false
end

#can_delete_branch?(ref) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/gitlab/user_access_snippet.rb', line 34

def can_delete_branch?(ref)
  false
end

#can_do_action?(action) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
# File 'lib/gitlab/user_access_snippet.rb', line 21

def can_do_action?(action)
  return false unless can_access_git?

  permission_cache[action] =
    permission_cache.fetch(action) do
      Ability.allowed?(user, action, snippet)
    end
end

#can_merge_to_branch?(ref) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/gitlab/user_access_snippet.rb', line 44

def can_merge_to_branch?(ref)
  false
end

#can_push_to_branch?(ref) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
# File 'lib/gitlab/user_access_snippet.rb', line 38

def can_push_to_branch?(ref)
  return false unless snippet

  can_do_action?(:update_snippet)
end