blob: 5919a2832836593045328f9c9a84be5b9d95b3dc (
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
43
44
45
46
47
48
|
module Gitlab
module Ci
class Config
module Node
##
# Factory class responsible for fabricating node entry objects.
#
class Factory
class InvalidFactory < StandardError; end
def initialize(node)
@node = node
@attributes = {}
end
def with(attributes)
@attributes.merge!(attributes)
self
end
def create!
raise InvalidFactory unless @attributes.has_key?(:value)
fabricate.tap do |entry|
entry.key = @attributes[:key]
entry.parent = @attributes[:parent]
entry.description = @attributes[:description]
end
end
private
def fabricate
##
# We assume that unspecified entry is undefined.
# See issue #18775.
#
if @attributes[:value].nil?
Node::Undefined.new(@node)
else
@node.new(@attributes[:value])
end
end
end
end
end
end
end
|