debian-mirror-gitlab/lib/gitlab/ci/config/normalizer/factory.rb

39 lines
744 B
Ruby
Raw Normal View History

2020-10-24 23:57:45 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
class Config
class Normalizer
class Factory
include Gitlab::Utils::StrongMemoize
def initialize(name, config)
@name = name
@config = config
end
def create
return [] unless strategy
strategy.build_from(@name, @config)
end
private
def strategy
strong_memoize(:strategy) do
strategies.find do |strategy|
strategy.applies_to?(@config)
end
end
end
def strategies
[NumberStrategy, MatrixStrategy]
end
end
end
end
end
end