Module: Cumuliform::Output
- Included in:
- Template
- Defined in:
- lib/cumuliform/output.rb
Overview
Manages converting the Cumuliform::Template into a CloudFormation JSON string
Instance Method Summary collapse
-
#to_hash ⇒ Hash
Processes the template and returns a hash representing the CloudFormation template.
-
#to_json ⇒ String
Generates the JSON representation of the template from the Hash representation provided by #to_hash.
Instance Method Details
#to_hash ⇒ Hash
Processes the template and returns a hash representing the CloudFormation template
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cumuliform/output.rb', line 14 def to_hash output = {} TOP_LEVEL.each do |item_name| value = get_top_level_value(item_name) output[item_name] = value unless value.nil? end SECTION_NAMES.each do |section_name| section = get_section(section_name) output[section_name] = generate_section(section) unless section.empty? end raise Error::NoResourcesDefined unless output.has_key?("Resources") output end |
#to_json ⇒ String
Generates the JSON representation of the template from the Hash representation provided by #to_hash
33 34 35 |
# File 'lib/cumuliform/output.rb', line 33 def to_json JSON.pretty_generate(to_hash) end |