Class: DDSL::TemplateMerger

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#dataObject (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

#applyHash

Note:

‘templates` key will be removed from objects after they are applied

Apply ‘build` and `run` templates to data

Returns:

  • (Hash)


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