Sha256: d3f955adf76be627896b87d46890160a38a9ce06a0ffac589b93314a2debfb7d

Contents?: true

Size: 1.08 KB

Versions: 104

Compression:

Stored size: 1.08 KB

Contents

# Implements:
#
#   compose
#   template_path
#
class Jets::Cfn::Builders
  class ControllerBuilder < BaseChildBuilder
    # compose is an interface method for Interface module
    def compose
      add_common_parameters
      add_api_gateway_parameters
      add_functions
      add_routes
    end

    def add_api_gateway_parameters
      return if Jets::Router.routes.empty?

      add_parameter("RestApi", Description: "RestApi")
      scoped_routes.each do |route|
        resource = Jets::Resource::ApiGateway::Resource.new(route.path)
        add_parameter(resource.logical_id, Description: resource.desc)
      end
    end

    def add_routes
      scoped_routes.each_with_index do |route, i|
        method = Jets::Resource::ApiGateway::Method.new(route)
        add_resource(method)
        add_resource(method.permission)
        add_resource(method.cors) if Jets.config.cors
      end
    end

    # routes scoped to this controller template.
    def scoped_routes
      @routes ||= Jets::Router.routes.select do |route|
        route.controller_name == @app_class.to_s
      end
    end
  end
end

Version data entries

104 entries across 104 versions & 2 rubygems

Version Path
jets-1.9.7 lib/jets/cfn/builders/controller_builder.rb
jets-1.9.6 lib/jets/cfn/builders/controller_builder.rb
jets-1.9.5 lib/jets/cfn/builders/controller_builder.rb
jets-1.9.4 lib/jets/cfn/builders/controller_builder.rb
jets-1.9.3 lib/jets/cfn/builders/controller_builder.rb
jets-1.9.2 lib/jets/cfn/builders/controller_builder.rb
jets-1.9.1 lib/jets/cfn/builders/controller_builder.rb
jets-1.9.0 lib/jets/cfn/builders/controller_builder.rb
jets-1.8.14 lib/jets/cfn/builders/controller_builder.rb
jets-1.8.13 lib/jets/cfn/builders/controller_builder.rb
jets-1.8.12 lib/jets/cfn/builders/controller_builder.rb
jets-1.8.11 lib/jets/cfn/builders/controller_builder.rb
jets-1.8.10 lib/jets/cfn/builders/controller_builder.rb
jets-1.8.9 lib/jets/cfn/builders/controller_builder.rb
jets-1.8.8 lib/jets/cfn/builders/controller_builder.rb
jets-1.8.7 lib/jets/cfn/builders/controller_builder.rb
jets-1.8.6 lib/jets/cfn/builders/controller_builder.rb
jets-1.8.5 lib/jets/cfn/builders/controller_builder.rb
jets-1.8.4 lib/jets/cfn/builders/controller_builder.rb
jets-1.8.3 lib/jets/cfn/builders/controller_builder.rb