summaryrefslogtreecommitdiff
path: root/lib/gitlab/config/entry/simplifiable.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/config/entry/simplifiable.rb')
-rw-r--r--lib/gitlab/config/entry/simplifiable.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/gitlab/config/entry/simplifiable.rb b/lib/gitlab/config/entry/simplifiable.rb
index d58aba07d15..315f1947e2c 100644
--- a/lib/gitlab/config/entry/simplifiable.rb
+++ b/lib/gitlab/config/entry/simplifiable.rb
@@ -4,11 +4,11 @@ module Gitlab
module Config
module Entry
class Simplifiable < SimpleDelegator
- EntryStrategy = Struct.new(:name, :condition)
+ EntryStrategy = Struct.new(:name, :klass, :condition)
attr_reader :subject
- def initialize(config, **metadata)
+ def initialize(config, **metadata, &blk)
unless self.class.const_defined?(:UnknownStrategy)
raise ArgumentError, 'UndefinedStrategy not available!'
end
@@ -19,14 +19,13 @@ module Gitlab
entry = self.class.entry_class(strategy)
- @subject = entry.new(config, metadata)
+ @subject = entry.new(config, metadata, &blk)
- yield(@subject) if block_given?
super(@subject)
end
def self.strategy(name, **opts)
- EntryStrategy.new(name, opts.fetch(:if)).tap do |strategy|
+ EntryStrategy.new(name, opts.dig(:class), opts.fetch(:if)).tap do |strategy|
strategies.append(strategy)
end
end
@@ -37,7 +36,7 @@ module Gitlab
def self.entry_class(strategy)
if strategy.present?
- self.const_get(strategy.name, false)
+ strategy.klass || self.const_get(strategy.name, false)
else
self::UnknownStrategy
end