blob: 19915980d7f9fa9723cda011e77073cfd26846dd (
plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
|
# frozen_string_literal: true
module Gitlab
class GlRepository
class RepoType
attr_reader :name,
:access_checker_class,
:repository_accessor
def initialize(name:, access_checker_class:, repository_accessor:)
@name = name
@access_checker_class = access_checker_class
@repository_accessor = repository_accessor
end
def identifier_for_subject(subject)
"#{name}-#{subject.id}"
end
def fetch_id(identifier)
match = /\A#{name}-(?<id>\d+)\z/.match(identifier)
match[:id] if match
end
def wiki?
self == WIKI
end
def project?
self == PROJECT
end
def path_suffix
project? ? "" : ".#{name}"
end
def repository_for(subject)
repository_accessor.call(subject)
end
end
end
end
|