Class: Gitlab::Ci::Config::Yaml::Tags::Resolver
- Inherits:
-
Object
- Object
- Gitlab::Ci::Config::Yaml::Tags::Resolver
- Defined in:
- lib/gitlab/ci/config/yaml/tags/resolver.rb
Overview
This class is the entry point for transforming custom YAML tags back into primitive objects. Usage: ‘Resolver.new(a_hash_including_custom_tag_objects).to_hash`
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #deep_resolve(object) ⇒ Object
-
#initialize(config) ⇒ Resolver
constructor
A new instance of Resolver.
- #resolve_wrapper(object) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(config) ⇒ Resolver
Returns a new instance of Resolver.
15 16 17 |
# File 'lib/gitlab/ci/config/yaml/tags/resolver.rb', line 15 def initialize(config) @config = config.deep_dup end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/gitlab/ci/config/yaml/tags/resolver.rb', line 13 def config @config end |
Instance Method Details
#deep_resolve(object) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gitlab/ci/config/yaml/tags/resolver.rb', line 23 def deep_resolve(object) case object when Array object.map(&method(:resolve_wrapper)) when Hash object.deep_transform_values(&method(:resolve_wrapper)) else resolve_wrapper(object) end end |
#resolve_wrapper(object) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/gitlab/ci/config/yaml/tags/resolver.rb', line 34 def resolve_wrapper(object) if object.respond_to?(:resolve) object.resolve(self) else object end end |
#to_hash ⇒ Object
19 20 21 |
# File 'lib/gitlab/ci/config/yaml/tags/resolver.rb', line 19 def to_hash deep_resolve(config) end |