diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-04 12:29:59 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-04 12:29:59 +0300 |
commit | eb151e77ff389c3e22454145cfd55cfaa4be7948 (patch) | |
tree | c74f67c27cd36555a45b50b848e9b1d3a34d05a2 /lib | |
parent | b4f03e8b1e94863949c567a305c8072b34d7e6a1 (diff) |
Extract CI configuration entry node factory method
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/config/node/factory.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/gitlab/ci/config/node/factory.rb b/lib/gitlab/ci/config/node/factory.rb index 85e28f345fe..5919a283283 100644 --- a/lib/gitlab/ci/config/node/factory.rb +++ b/lib/gitlab/ci/config/node/factory.rb @@ -21,20 +21,24 @@ module Gitlab 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, value = Node::Undefined, @node + Node::Undefined.new(@node) else - node, value = @node, @attributes[:value] - end - - node.new(value).tap do |entry| - entry.key = @attributes[:key] - entry.parent = @attributes[:parent] - entry.description = @attributes[:description] + @node.new(@attributes[:value]) end end end |