class TFDSL::Stack
This class is the representation of a terraform stack, or in another words is a collection of terraform configuration blocks
Public Class Methods
new(&block)
click to toggle source
# File lib/tfdsl/stack.rb, line 6 def initialize(&block) @objects = [] instance_eval(&block) if block_given? end
Public Instance Methods
to_json()
click to toggle source
# File lib/tfdsl/stack.rb, line 26 def to_json stack = {} @objects.each do |obj| key = KindTranslator.kind obj.class stack[key] = {} if stack[key].nil? stack[key] = stack[key].deep_merge obj.to_json_repr end JSON.pretty_generate(stack) end
to_s()
click to toggle source
# File lib/tfdsl/stack.rb, line 22 def to_s @objects.each_with_object('') { |o, str| str << o } end