Module: ProtectedRefAccess

Extended by:
ActiveSupport::Concern
Included in:
ProtectedBranchAccess, ProtectedTagAccess
Defined in:
app/models/concerns/protected_ref_access.rb

Constant Summary collapse

HUMAN_ACCESS_LEVELS =
{
  Gitlab::Access::MAINTAINER => "Maintainers",
  Gitlab::Access::DEVELOPER => "Developers + Maintainers",
  Gitlab::Access::NO_ACCESS => "No one"
}.freeze

Instance Method Summary collapse

Instance Method Details

#check_access(user) ⇒ Object


47
48
49
50
51
52
53
# File 'app/models/concerns/protected_ref_access.rb', line 47

def check_access(user)
  return false unless user
  return true if user.admin?

  user.can?(:push_code, project) &&
    project.team.max_member_access(user.id) >= access_level
end

#humanizeObject


35
36
37
# File 'app/models/concerns/protected_ref_access.rb', line 35

def humanize
  HUMAN_ACCESS_LEVELS[self.access_level]
end

#role?Boolean

Returns:

  • (Boolean)

43
44
45
# File 'app/models/concerns/protected_ref_access.rb', line 43

def role?
  type == :role
end

#typeObject


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

def type
  :role
end