Sha256: 4070d90816dd68ae3ef3b39e18a8dfac18dcd40c0bfaf09b4f82adc1ab8e9395

Contents?: true

Size: 925 Bytes

Versions: 10

Compression:

Stored size: 925 Bytes

Contents

class Lono::Template::Dsl::Builder
  class Base
    include Fn
    include Helpers

    def initialize(blueprint, *definition)
      @blueprint = blueprint
      @definition = definition.flatten
    end

  private
    def camelize(attributes)
      blueprint_meta = Lono::Blueprint::Meta.new(@blueprint)
      target_section = self.class.to_s.split('::').last.underscore
      # target_section: Lono::Template::Dsl::Builder::Parameter => parameter
      if blueprint_meta.auto_camelize?(target_section)
        CfnCamelizer.transform(attributes)
      else
        stringify_keys!(attributes)
      end
    end

    # Accounts for Arrays also. ActiveSupport only works for Hashes.
    def stringify_keys!(data)
      case data
      when Array
        data.map! { |i| stringify_keys!(i) }
      when Hash
        data.deep_transform_keys! { |k| k.to_s }
      else
        data # do not transform
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
lono-6.1.7 lib/lono/template/dsl/builder/base.rb
lono-6.1.6 lib/lono/template/dsl/builder/base.rb
lono-6.1.5 lib/lono/template/dsl/builder/base.rb
lono-6.1.4 lib/lono/template/dsl/builder/base.rb
lono-6.1.3 lib/lono/template/dsl/builder/base.rb
lono-6.1.2 lib/lono/template/dsl/builder/base.rb
lono-6.1.1 lib/lono/template/dsl/builder/base.rb
lono-6.1.0 lib/lono/template/dsl/builder/base.rb
lono-6.0.1 lib/lono/template/dsl/builder/base.rb
lono-6.0.0 lib/lono/template/dsl/builder/base.rb