From eb151e77ff389c3e22454145cfd55cfaa4be7948 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 4 Jul 2016 11:29:59 +0200 Subject: [PATCH] Extract CI configuration entry node factory method --- lib/gitlab/ci/config/node/factory.rb | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/gitlab/ci/config/node/factory.rb b/lib/gitlab/ci/config/node/factory.rb index 85e28f345f..5919a28328 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