Sha256: 073315b6ba864373594d1b06957751e702e9b1e0bc1ca9eb6088fe440113fa4f

Contents?: true

Size: 803 Bytes

Versions: 5

Compression:

Stored size: 803 Bytes

Contents

# Implements:
#
#   template - uses @definition to build a CloudFormation template section
#
module Lono::Builder::Dsl::Syntax::Core
  class Condition < Base
    def template
      camelize(standarize(@definition))
    end

    # There are only 2 forms for condition: long and medium
    #
    # Type is the only required property: https://amzn.to/2x8W5aD
    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 }
      else # I dont know what form
        raise "Invalid form provided. definition #{definition.inspect}"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lono-8.0.0.pre.rc6 lib/lono/builder/dsl/syntax/core/condition.rb
lono-8.0.0.pre.rc5 lib/lono/builder/dsl/syntax/core/condition.rb
lono-8.0.0.pre.rc4 lib/lono/builder/dsl/syntax/core/condition.rb
lono-8.0.0.pre.rc3 lib/lono/builder/dsl/syntax/core/condition.rb
lono-8.0.0.pre.rc2 lib/lono/builder/dsl/syntax/core/condition.rb