Class: DDSL::TemplateMerger
- Inherits:
-
Object
- Object
- DDSL::TemplateMerger
- Defined in:
- lib/ddsl/template_merger.rb
Defined Under Namespace
Classes: MissingTemplateError, ValueTypeMismatchError
Constant Summary collapse
- SKIPPABLE_TEMPLATE_KEYS =
Set of keys that can’t be extracted from a template
%w[name].freeze
- SKIPPABLE_MERGE_KEYS =
Set of keys that can’t be merged in a templatable hash
%w[templates].freeze
- TEMPLETABLE_KEYS =
Keys that can use the templates feature
%w[builds runs].freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#apply ⇒ Hash
Apply ‘build` and `run` templates to data.
-
#initialize(data) ⇒ TemplateMerger
constructor
A new instance of TemplateMerger.
Constructor Details
#initialize(data) ⇒ TemplateMerger
Returns a new instance of TemplateMerger.
19 20 21 |
# File 'lib/ddsl/template_merger.rb', line 19 def initialize(data) @data = data.dup end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
17 18 19 |
# File 'lib/ddsl/template_merger.rb', line 17 def data @data end |
Instance Method Details
#apply ⇒ Hash
Note:
‘templates` key will be removed from objects after they are applied
Apply ‘build` and `run` templates to data
30 31 32 33 34 35 36 |
# File 'lib/ddsl/template_merger.rb', line 30 def apply TEMPLETABLE_KEYS.each do |key| data[key] = data[key].map { |b| apply_templates(b) } if data.key?(key) end data end |