2016-06-09 04:08:49 -04:00
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
class Config
|
|
|
|
module Node
|
|
|
|
module Configurable
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
def keys
|
|
|
|
self.class.nodes || {}
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-06-09 04:53:56 -04:00
|
|
|
def add_node(key, metadata)
|
|
|
|
entry = create_entry(key, metadata[:class])
|
|
|
|
entry.description = metadata[:description]
|
|
|
|
|
|
|
|
@nodes[key] = entry
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_entry(key, entry_class)
|
2016-06-09 04:08:49 -04:00
|
|
|
if @value.has_key?(key)
|
2016-06-09 04:53:56 -04:00
|
|
|
entry_class.new(@value[key], @root, self)
|
2016-06-09 04:08:49 -04:00
|
|
|
else
|
2016-06-09 04:53:56 -04:00
|
|
|
Node::Null.new(nil, @root, self)
|
2016-06-09 04:08:49 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class_methods do
|
|
|
|
attr_reader :nodes
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-06-09 04:53:56 -04:00
|
|
|
def add_node(symbol, entry_class, metadata)
|
|
|
|
node = { symbol.to_sym =>
|
|
|
|
{ class: entry_class,
|
|
|
|
description: metadata[:description] } }
|
2016-06-09 04:08:49 -04:00
|
|
|
|
|
|
|
(@nodes ||= {}).merge!(node)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|