Class: Gitlab::Ci::Config::Interpolation::Context
- Inherits:
-
Object
- Object
- Gitlab::Ci::Config::Interpolation::Context
- Defined in:
- lib/gitlab/ci/config/interpolation/context.rb
Overview
Interpolation::Context is a class that represents the data that can be used when performing string interpolation on a CI configuration.
Constant Summary collapse
- ContextTooComplexError =
Class.new(StandardError)
- NotSymbolizedContextError =
Class.new(StandardError)
- MAX_DEPTH =
3
Instance Method Summary collapse
- #depth ⇒ Object
-
#errors ⇒ Object
This method is here because ‘Context` will be responsible for validating specs, inputs and defaults.
- #fetch(field) ⇒ Object
-
#initialize(hash) ⇒ Context
constructor
A new instance of Context.
- #key?(name) ⇒ Boolean
- #to_h ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(hash) ⇒ Context
Returns a new instance of Context.
17 18 19 20 21 |
# File 'lib/gitlab/ci/config/interpolation/context.rb', line 17 def initialize(hash) @context = hash raise ContextTooComplexError if depth > MAX_DEPTH end |
Instance Method Details
#depth ⇒ Object
34 35 36 |
# File 'lib/gitlab/ci/config/interpolation/context.rb', line 34 def depth deep_depth(@context) end |
#errors ⇒ Object
This method is here because ‘Context` will be responsible for validating specs, inputs and defaults.
30 31 32 |
# File 'lib/gitlab/ci/config/interpolation/context.rb', line 30 def errors [] end |
#fetch(field) ⇒ Object
38 39 40 |
# File 'lib/gitlab/ci/config/interpolation/context.rb', line 38 def fetch(field) @context.fetch(field) end |
#key?(name) ⇒ Boolean
42 43 44 |
# File 'lib/gitlab/ci/config/interpolation/context.rb', line 42 def key?(name) @context.key?(name) end |
#to_h ⇒ Object
46 47 48 |
# File 'lib/gitlab/ci/config/interpolation/context.rb', line 46 def to_h @context.to_h end |
#valid? ⇒ Boolean
23 24 25 |
# File 'lib/gitlab/ci/config/interpolation/context.rb', line 23 def valid? errors.none? end |