1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
# frozen_string_literal: true
class ProtectedBranch::CacheKey # rubocop:disable Style/ClassAndModuleChildren -- Same problem as in push_access_level.rb
include Gitlab::Utils::StrongMemoize
CACHE_ROOT_KEY = 'cache:gitlab:protected_branch'
def initialize(entity)
@entity = entity
end
def to_s
[CACHE_ROOT_KEY, entity_scope, entity.id].join(':')
end
private
attr_reader :entity
def entity_scope
case entity
when Group
'group'
when Project
'project'
else
entity.class.name.downcase
end
end
end
|