Class: Gitlab::UserAccessSnippet
- Inherits:
-
UserAccess
- Object
- UserAccess
- Gitlab::UserAccessSnippet
- Extended by:
- Cache::RequestCache, Gitlab::Utils::Override
- Defined in:
- lib/gitlab/user_access_snippet.rb
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Attributes included from Cache::RequestCache
Attributes inherited from UserAccess
#container, #push_ability, #user
Instance Method Summary collapse
- #can_create_tag?(ref) ⇒ Boolean
- #can_delete_branch?(ref) ⇒ Boolean
- #can_do_action?(action) ⇒ Boolean
- #can_merge_to_branch?(ref) ⇒ Boolean
- #can_push_to_branch?(ref) ⇒ Boolean
-
#initialize(user, snippet: nil) ⇒ UserAccessSnippet
constructor
A new instance of UserAccessSnippet.
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
#project ⇒ Object (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
30 31 32 |
# File 'lib/gitlab/user_access_snippet.rb', line 30 def can_create_tag?(ref) false end |
#can_delete_branch?(ref) ⇒ 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
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? [action] = .fetch(action) do Ability.allowed?(user, action, snippet) end end |
#can_merge_to_branch?(ref) ⇒ 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
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 |