Class: Gitlab::Config::Entry::Simplifiable
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Gitlab::Config::Entry::Simplifiable
- Defined in:
- lib/gitlab/config/entry/simplifiable.rb
Direct Known Subclasses
Gitlab::Ci::Config::Entry::Inherit::Default, Gitlab::Ci::Config::Entry::Inherit::Variables, Gitlab::Ci::Config::Entry::Key, Gitlab::Ci::Config::Entry::Need, Gitlab::Ci::Config::Entry::Policy, Gitlab::Ci::Config::Entry::Product::Parallel, Gitlab::Ci::Config::Entry::Retry, Gitlab::Ci::Config::Entry::Rules::Rule::Changes, Gitlab::Ci::Config::Entry::Trigger, Gitlab::Ci::Config::Entry::Trigger::ComplexTrigger, Gitlab::Ci::Config::Entry::Variable
Defined Under Namespace
Classes: EntryStrategy
Instance Attribute Summary collapse
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Class Method Summary collapse
- .default ⇒ Object
- .entry_class(strategy) ⇒ Object
- .strategies ⇒ Object
- .strategy(name, **opts) ⇒ Object
Instance Method Summary collapse
-
#initialize(config, **metadata, &blk) ⇒ Simplifiable
constructor
A new instance of Simplifiable.
Constructor Details
#initialize(config, **metadata, &blk) ⇒ Simplifiable
Returns a new instance of Simplifiable.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gitlab/config/entry/simplifiable.rb', line 11 def initialize(config, **, &blk) unless self.class.const_defined?(:UnknownStrategy) raise ArgumentError, 'UndefinedStrategy not available!' end strategy = self.class.strategies.find do |variant| variant.condition.call(config) end entry = self.class.entry_class(strategy) @subject = entry.new(config, **, &blk) super(@subject) end |
Instance Attribute Details
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
9 10 11 |
# File 'lib/gitlab/config/entry/simplifiable.rb', line 9 def subject @subject end |
Class Method Details
.default ⇒ Object
45 46 |
# File 'lib/gitlab/config/entry/simplifiable.rb', line 45 def self.default end |
.entry_class(strategy) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/gitlab/config/entry/simplifiable.rb', line 37 def self.entry_class(strategy) if strategy.present? strategy.klass || self.const_get(strategy.name, false) else self::UnknownStrategy end end |
.strategies ⇒ Object
33 34 35 |
# File 'lib/gitlab/config/entry/simplifiable.rb', line 33 def self.strategies @strategies ||= [] end |
.strategy(name, **opts) ⇒ Object
27 28 29 30 31 |
# File 'lib/gitlab/config/entry/simplifiable.rb', line 27 def self.strategy(name, **opts) EntryStrategy.new(name, opts.dig(:class), opts.fetch(:if)).tap do |strategy| strategies.append(strategy) end end |