Sha256: f40ce020ebdf726ebc874ce61f765a692a3de789b3279cd7ddd636bf9eadd8c2

Contents?: true

Size: 1.02 KB

Versions: 22

Compression:

Stored size: 1.02 KB

Contents

class Jets::Cfn::TemplateMappers
  class ControllerMapper < ChildMapper
    # Parameters that are common to all controller stacks
    def parameters
      parameters = super
      return parameters if Jets::Router.routes.empty?

      # Add the API Gateway parameters
      parameters[:RestApi] = "!GetAtt ApiGateway.Outputs.RestApi"
      scoped_routes.each do |route|
        map = GatewayResourceMapper.new(route.path)
        parameters[map.logical_id] = "!GetAtt ApiGateway.Outputs.#{map.logical_id}"
      end

      parameters
    end

    def scoped_routes
      @routes ||= Jets::Router.routes.select do |route|
        route.controller_name == current_class
      end
    end

      # Example:
      #   1. demo-stag-admin-related_pages_controller.yml
      #   2. admin/posts_controller
      #   3. Admin::PostsController
    def current_class
      templates_prefix = "#{Jets::Naming.template_path_prefix}-"
      @path.sub(templates_prefix, '')
        .sub(/\.yml$/,'')
        .gsub('-','/')
        .classify
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
jets-0.8.0 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.7.1 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.7.0 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.6.9 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.6.8 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.6.7 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.6.6 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.6.5 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.6.4 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.6.3 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.6.2 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.6.1 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.6.0 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.5.8 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.5.7 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.5.6 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.5.5 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.5.4 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.5.3 lib/jets/cfn/template_mappers/controller_mapper.rb
jets-0.5.2 lib/jets/cfn/template_mappers/controller_mapper.rb