Sha256: 70f6234cd672d1ca4751f9e07716efc8828161c4f98e564eaf5c5ceaf23e6d2d

Contents?: true

Size: 1.05 KB

Versions: 15

Compression:

Stored size: 1.05 KB

Contents

# Detects route variable changes
class Jets::Cfn::Resource::ApiGateway::RestApi::Routes::Change
  class Variable < Base
    def changed?
      changed = false
      deployed_routes.each do |deployed_route|
        parent = collision.variable_parent(deployed_route.path)
        parent_variables = collision.parent_variables(parent, [deployed_route.path])
        new_parent_variables = collision.parent_variables(parent, new_paths)

        changed = parent_variables.size > 0 && new_parent_variables.size > 0 &&
                  parent_variables != new_parent_variables
        break if changed
      end
      changed
    end

    # Only consider paths with variables
    def new_paths
      new_routes.map(&:path).select {|p| p.include?(':')}.uniq
    end

    # Only consider deployed routes with variables
    def deployed_routes
      deployed_routes = super
      deployed_routes.select do |route|
        route.path.include?(':')
      end
    end

    def collision
      @collision ||= Jets::Cfn::Resource::ApiGateway::RestApi::Routes::Collision.new
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/cfn/resource/api_gateway/rest_api/routes/change/variable.rb
jets-5.0.12 lib/jets/cfn/resource/api_gateway/rest_api/routes/change/variable.rb
jets-5.0.11 lib/jets/cfn/resource/api_gateway/rest_api/routes/change/variable.rb
jets-5.0.10 lib/jets/cfn/resource/api_gateway/rest_api/routes/change/variable.rb
jets-5.0.9 lib/jets/cfn/resource/api_gateway/rest_api/routes/change/variable.rb
jets-5.0.8 lib/jets/cfn/resource/api_gateway/rest_api/routes/change/variable.rb
jets-5.0.7 lib/jets/cfn/resource/api_gateway/rest_api/routes/change/variable.rb
jets-5.0.6 lib/jets/cfn/resource/api_gateway/rest_api/routes/change/variable.rb
jets-5.0.5 lib/jets/cfn/resource/api_gateway/rest_api/routes/change/variable.rb
jets-5.0.4 lib/jets/cfn/resource/api_gateway/rest_api/routes/change/variable.rb
jets-5.0.3 lib/jets/cfn/resource/api_gateway/rest_api/routes/change/variable.rb
jets-5.0.2 lib/jets/cfn/resource/api_gateway/rest_api/routes/change/variable.rb
jets-5.0.1 lib/jets/cfn/resource/api_gateway/rest_api/routes/change/variable.rb
jets-5.0.0 lib/jets/cfn/resource/api_gateway/rest_api/routes/change/variable.rb
jets-5.0.0.beta1 lib/jets/cfn/resource/api_gateway/rest_api/routes/change/variable.rb