From 67e90a123f4086b9110f081b204be2250459bbc7 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 14 Jan 2019 14:27:31 +0100 Subject: [PATCH] Make fabrication of default config entry more readable --- lib/gitlab/ci/config/entry/job.rb | 2 +- lib/gitlab/config/entry/factory.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/gitlab/ci/config/entry/job.rb b/lib/gitlab/ci/config/entry/job.rb index 5a810cc6436..326f2df1ea7 100644 --- a/lib/gitlab/ci/config/entry/job.rb +++ b/lib/gitlab/ci/config/entry/job.rb @@ -150,7 +150,7 @@ module Gitlab stage: stage_value, cache: cache_value, only: only_value, - except: except_value.to_h, + except: except_value, variables: variables_defined? ? variables_value : nil, environment: environment_defined? ? environment_value : nil, environment_name: environment_defined? ? environment_value[:name] : nil, diff --git a/lib/gitlab/config/entry/factory.rb b/lib/gitlab/config/entry/factory.rb index 39edfa332b4..089a20dd324 100644 --- a/lib/gitlab/config/entry/factory.rb +++ b/lib/gitlab/config/entry/factory.rb @@ -53,10 +53,12 @@ module Gitlab # If entry has a default value we fabricate concrete node # with default value. # - if @entry.default(@attributes).nil? - fabricate(Entry::Undefined) - else - fabricate(@entry, @entry.default(@attributes)) + @entry.default(@attributes).yield_self do |default| + if default.nil? + fabricate(Entry::Undefined) + else + fabricate(@entry, default) + end end end