Sha256: 9db5384e9ea7e54e42951e5d86957de03678aa04c0073f8f77ced6324605904c
Contents?: true
Size: 996 Bytes
Versions: 1
Compression:
Stored size: 996 Bytes
Contents
# frozen_string_literal: true module Tataru # compiles the inithash class InitHashCompiler def initialize(dsl) @dsl = dsl end def resolved_references(resource_name, references) references.map do |field, refname| [field, refname.to_s.sub(/^top/, resource_name)] end.to_h end def generate_init_hash rom = {} @dsl.resources.each do |k, v| # Expand all the values used to a big flat hash that # is only one level deep for ease of use, then mark # them for the vm to use flattener = Flattener.new(v) flattener.flattened.each do |key, value| fixed = value.dup if fixed[:references] fixed[:references] = resolved_references(k, fixed[:references]) end rom[key.to_s.sub(/^top/, k)] = fixed end end { rom: rom, remote_ids: {} } end def result @result ||= generate_init_hash end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tataru-0.2.0 | lib/tataru/init_hash_compiler.rb |