lib/ruby_terraform/models/map.rb in ruby-terraform-1.7.0.pre.6 vs lib/ruby_terraform/models/map.rb in ruby-terraform-1.7.0.pre.7

- old
+ new

@@ -45,9 +45,24 @@ def sensitive? @sensitive end + def render(bare: false, level: 0, indent: ' ') + return '{}' if empty? + + next_level = bare ? level : level + 1 + self_indent = bare ? '' : indent + opts = { level: next_level, indent: indent } + extra = level.times.collect { |_| indent }.join + lines = + value + .collect { |k, v| "#{extra}#{self_indent}#{k} = #{v.render(opts)}" } + .join("\n") + + bare ? lines : "{\n#{lines}\n#{extra}}" + end + def state [@value, @sensitive] end def inspect