Class: Gitlab::VisibilityLevelChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/visibility_level_checker.rb

Instance Method Summary collapse

Constructor Details

#initialize(current_user, project, project_params: {}) ⇒ VisibilityLevelChecker

Returns a new instance of VisibilityLevelChecker.


32
33
34
35
36
# File 'lib/gitlab/visibility_level_checker.rb', line 32

def initialize(current_user, project, project_params: {})
  @current_user   = current_user
  @project        = project
  @project_params = project_params
end

Instance Method Details

#level_restricted?Boolean

Returns:

  • (Boolean)

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

def level_restricted?
  return VisibilityEvaluationResult.new(true, override_visibility_level_value) if override_visibility_restricted?
  return VisibilityEvaluationResult.new(true, project.visibility_level) if project_visibility_restricted?

  VisibilityEvaluationResult.new(false, nil)
end