Class: Gitlab::GlRepository::Identifier
- Inherits:
-
Object
- Object
- Gitlab::GlRepository::Identifier
show all
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/gl_repository/identifier.rb
Defined Under Namespace
Classes: ThreePartIdentifier, TwoPartIdentifier
Constant Summary
collapse
- InvalidIdentifier =
Class.new(ArgumentError)
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.parse(gl_repository) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/gitlab/gl_repository/identifier.rb', line 10
def self.parse(gl_repository)
segments = gl_repository&.split('-')
identifier = case segments&.size
when 2
TwoPartIdentifier.new(*segments)
when 3
ThreePartIdentifier.new(*segments)
end
return identifier if identifier&.valid?
raise InvalidIdentifier, %(Invalid GL Repository "#{gl_repository}")
end
|
Instance Method Details
#container ⇒ Object
70
71
72
|
# File 'lib/gitlab/gl_repository/identifier.rb', line 70
def container
strong_memoize(:container) { container_class.find_by_id(container_id) }
end
|
#repo_type ⇒ Object
66
67
68
|
# File 'lib/gitlab/gl_repository/identifier.rb', line 66
def repo_type
strong_memoize(:repo_type) { Gitlab::GlRepository.types[repo_type_name] }
end
|
#valid? ⇒ Boolean
74
75
76
|
# File 'lib/gitlab/gl_repository/identifier.rb', line 74
def valid?
repo_type.present? && container_class.present? && container_id&.positive?
end
|