Sha256: b53aa2acc0f8e4193add74090f1abae6cd0e3c84797297046022d5cf3acdf92b

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

class Jets::Cfn::TemplateBuilders
  class BaseChildBuilder
    include Interface

    # The app_klass is can be a controller, job or anonymous function class.
    # IE: PostsController, HardJob
    def initialize(app_klass)
      @app_klass = app_klass
      @template = ActiveSupport::HashWithIndifferentAccess.new(Resources: {})
    end

    # template_path is an interface method for Interface module
    def template_path
      Jets::Naming.template_path(@app_klass)
    end

    def add_common_parameters
      add_parameter("IamRole", Description: "Iam Role that Lambda function uses.")
      add_parameter("S3Bucket", Description: "S3 Bucket for source code.")
    end

    def add_functions
      @app_klass.tasks.each do |task|
        add_function(task)
      end
    end

    def add_function(task)
      # Examples:
      #   FunctionProperties::RubyBuilder
      #   FunctionProperties::PythonBuilder
      builder_class = "Jets::Cfn::TemplateBuilders::FunctionProperties::#{task.lang.to_s.classify}Builder".constantize
      builder = builder_class.new(task)
      logical_id = builder.map.logical_id
      add_resource(logical_id, "AWS::Lambda::Function", builder.properties)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
jets-0.5.8 lib/jets/cfn/template_builders/base_child_builder.rb
jets-0.5.7 lib/jets/cfn/template_builders/base_child_builder.rb
jets-0.5.6 lib/jets/cfn/template_builders/base_child_builder.rb
jets-0.5.5 lib/jets/cfn/template_builders/base_child_builder.rb
jets-0.5.4 lib/jets/cfn/template_builders/base_child_builder.rb
jets-0.5.3 lib/jets/cfn/template_builders/base_child_builder.rb
jets-0.5.2 lib/jets/cfn/template_builders/base_child_builder.rb
jets-0.5.1 lib/jets/cfn/template_builders/base_child_builder.rb
jets-0.5.0 lib/jets/cfn/template_builders/base_child_builder.rb