Sha256: cb309a2c83d4052bc409e8ac68309966687b052b2526304ef456a6bc8c0d4978

Contents?: true

Size: 1.07 KB

Versions: 15

Compression:

Stored size: 1.07 KB

Contents

# Implements:
#
#   template - uses @definition to build a CloudFormation template section
#
class Jets::Stack
  class Output
    include Definition

    def template
      camelize(standarize(@definition))
    end

    # Value is the only required property: https://amzn.to/2xbhmk3
    def standarize(definition)
      first, second, _ = definition
      if definition.size == 1 && first.is_a?(Hash) # long form
        first # pass through
      elsif definition.size == 2 && second.is_a?(Hash) # medium form
        logical_id, properties = first, second
        { logical_id => properties }
      elsif definition.size == 2 && second.is_a?(String) # short form
        logical_id = first
        properties = second.is_a?(String) ? { Value: second } : {}
        { logical_id => properties }
      elsif definition.size == 1
        logical_id = first.to_s
        properties = {Value: "!Ref #{logical_id.camelize}"}
        { logical_id => properties }
      else # I dont know what form
        raise "Invalid form provided. definition #{definition.inspect}"
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/stack/output.rb
jets-5.0.12 lib/jets/stack/output.rb
jets-5.0.11 lib/jets/stack/output.rb
jets-5.0.10 lib/jets/stack/output.rb
jets-5.0.9 lib/jets/stack/output.rb
jets-5.0.8 lib/jets/stack/output.rb
jets-5.0.7 lib/jets/stack/output.rb
jets-5.0.6 lib/jets/stack/output.rb
jets-5.0.5 lib/jets/stack/output.rb
jets-5.0.4 lib/jets/stack/output.rb
jets-5.0.3 lib/jets/stack/output.rb
jets-5.0.2 lib/jets/stack/output.rb
jets-5.0.1 lib/jets/stack/output.rb
jets-5.0.0 lib/jets/stack/output.rb
jets-5.0.0.beta1 lib/jets/stack/output.rb