diff options
Diffstat (limited to 'lib/gitlab/ci/variables/collection.rb')
-rw-r--r-- | lib/gitlab/ci/variables/collection.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/gitlab/ci/variables/collection.rb b/lib/gitlab/ci/variables/collection.rb index 9960a6fbdf5..f77ef262236 100644 --- a/lib/gitlab/ci/variables/collection.rb +++ b/lib/gitlab/ci/variables/collection.rb @@ -8,6 +8,21 @@ module Gitlab attr_reader :errors + def self.fabricate(input) + case input + when Array + new(input) + when Hash + new(input.map { |key, value| { key: key, value: value } }) + when Proc + fabricate(input.call) + when self + input + else + raise ArgumentError, "Unknown `#{input.class}` variable collection!" + end + end + def initialize(variables = [], errors = nil) @variables = [] @variables_by_key = Hash.new { |h, k| h[k] = [] } |