Class: Gitlab::Ci::Config::Interpolation::Template
- Inherits:
-
Object
- Object
- Gitlab::Ci::Config::Interpolation::Template
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/ci/config/interpolation/template.rb
Constant Summary collapse
- TooManyBlocksError =
Class.new(StandardError)
- InvalidBlockError =
Class.new(StandardError)
- MAX_BLOCKS =
10_000
Instance Attribute Summary collapse
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(config, ctx) ⇒ Template
constructor
A new instance of Template.
- #interpolated ⇒ Object
- #size ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(config, ctx) ⇒ Template
Returns a new instance of Template.
17 18 19 20 21 22 23 24 |
# File 'lib/gitlab/ci/config/interpolation/template.rb', line 17 def initialize(config, ctx) @config = Interpolation::Config.fabricate(config) @ctx = Interpolation::Context.fabricate(ctx) @errors = [] @blocks = {} interpolate! if valid? end |
Instance Attribute Details
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks.
10 11 12 |
# File 'lib/gitlab/ci/config/interpolation/template.rb', line 10 def blocks @blocks end |
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
10 11 12 |
# File 'lib/gitlab/ci/config/interpolation/template.rb', line 10 def ctx @ctx end |
Instance Method Details
#errors ⇒ Object
30 31 32 |
# File 'lib/gitlab/ci/config/interpolation/template.rb', line 30 def errors @errors + @config.errors + @ctx.errors + @blocks.values.flat_map(&:errors) end |
#interpolated ⇒ Object
38 39 40 |
# File 'lib/gitlab/ci/config/interpolation/template.rb', line 38 def interpolated @result if valid? end |
#size ⇒ Object
34 35 36 |
# File 'lib/gitlab/ci/config/interpolation/template.rb', line 34 def size @blocks.size end |
#valid? ⇒ Boolean
26 27 28 |
# File 'lib/gitlab/ci/config/interpolation/template.rb', line 26 def valid? errors.none? end |