Class: Gitlab::Ci::Config::Interpolation::Block
- Inherits:
-
Object
- Object
- Gitlab::Ci::Config::Interpolation::Block
- Defined in:
- lib/gitlab/ci/config/interpolation/block.rb
Overview
This class represents an interpolation block. The format supported is: $[[ <access> | <function1> | <function2> | … <functionN> ]]
<access> specifies the value to retrieve (e.g. inputs.key). <function> can be optionally provided with or without arguments to manipulate the access value. Functions are evaluated in the order they are presented.
Constant Summary collapse
- MAX_FUNCTIONS =
3- SKIP_INTERPOLATION_CONTEXTS =
%w[matrix].freeze
Instance Attribute Summary collapse
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(block, data, ctx) ⇒ Block
constructor
A new instance of Block.
- #length ⇒ Object
- #to_s ⇒ Object
- #valid? ⇒ Boolean
- #value ⇒ Object
Constructor Details
#initialize(block, data, ctx) ⇒ Block
Returns a new instance of Block.
21 22 23 24 25 26 27 28 29 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 21 def initialize(block, data, ctx) @block = block @data = data @ctx = ctx @errors = [] @value = nil evaluate! end |
Instance Attribute Details
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
19 20 21 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 19 def ctx @ctx end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
19 20 21 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 19 def data @data end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
19 20 21 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 19 def errors @errors end |
Instance Method Details
#content ⇒ Object
35 36 37 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 35 def content data end |
#length ⇒ Object
45 46 47 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 45 def length block.length end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 49 def to_s block end |
#valid? ⇒ Boolean
31 32 33 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 31 def valid? errors.none? end |
#value ⇒ Object
39 40 41 42 43 |
# File 'lib/gitlab/ci/config/interpolation/block.rb', line 39 def value raise ArgumentError, 'block invalid' unless valid? @value end |