Class: Gitlab::Repositories::RepoType

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

Instance Method Summary collapse

Instance Method Details

#access_checker_classObject

Raises:



10
11
12
# File 'lib/gitlab/repositories/repo_type.rb', line 10

def access_checker_class
  raise NotImplementedError, 'Define an access_checker_class in a RepoType subclass'
end

#container_classObject

Raises:



20
21
22
# File 'lib/gitlab/repositories/repo_type.rb', line 20

def container_class
  raise NotImplementedError, 'Define a container_class in a RepoType subclass'
end

#design?Boolean

Returns:



44
45
46
# File 'lib/gitlab/repositories/repo_type.rb', line 44

def design?
  name == :design
end

#guest_read_abilityObject

Raises:



14
15
16
# File 'lib/gitlab/repositories/repo_type.rb', line 14

def guest_read_ability
  raise NotImplementedError, 'Define a guest_read_ability in a RepoType subclass'
end

#identifier_for_container(container) ⇒ Object



28
29
30
# File 'lib/gitlab/repositories/repo_type.rb', line 28

def identifier_for_container(container)
  "#{name}-#{container.id}"
end

#nameObject

Raises:



6
7
8
# File 'lib/gitlab/repositories/repo_type.rb', line 6

def name
  raise NotImplementedError, 'Define a name in a RepoType subclass'
end

#path_suffixObject



48
49
50
# File 'lib/gitlab/repositories/repo_type.rb', line 48

def path_suffix
  suffix ? ".#{suffix}" : ''
end

#project?Boolean

Returns:



36
37
38
# File 'lib/gitlab/repositories/repo_type.rb', line 36

def project?
  name == :project
end

#project_for(container) ⇒ Object

Raises:



59
60
61
# File 'lib/gitlab/repositories/repo_type.rb', line 59

def project_for(container)
  raise NotImplementedError, 'Define a project_for in a RepoType subclass'
end

#repository_for(container) ⇒ Object



52
53
54
55
56
57
# File 'lib/gitlab/repositories/repo_type.rb', line 52

def repository_for(container)
  check_container(container)
  return unless container

  repository_resolver(container)
end

#snippet?Boolean

Returns:



40
41
42
# File 'lib/gitlab/repositories/repo_type.rb', line 40

def snippet?
  name == :snippet
end

#suffixObject



18
# File 'lib/gitlab/repositories/repo_type.rb', line 18

def suffix = nil

#type_idObject



24
25
26
# File 'lib/gitlab/repositories/repo_type.rb', line 24

def type_id
  name.to_s
end

#valid?(repository_path) ⇒ Boolean

Returns:



63
64
65
66
67
68
69
# File 'lib/gitlab/repositories/repo_type.rb', line 63

def valid?(repository_path)
  repository_path.end_with?(path_suffix) &&
    (
      !snippet? ||
      repository_path.match?(Gitlab::PathRegex.full_snippets_repository_path_regex)
    )
end

#wiki?Boolean

Returns:



32
33
34
# File 'lib/gitlab/repositories/repo_type.rb', line 32

def wiki?
  name == :wiki
end