Sha256: 7a39a0d8bf806333da318c64bfa8b5dec0700ae62368d773327b10583dea3dc4

Contents?: true

Size: 1.01 KB

Versions: 11

Compression:

Stored size: 1.01 KB

Contents

module Aws
  module Resources
    module Validator
      # @api private
      class PathResolver

        def initialize(api)
          @api = api
        end

        # @param [String<JMESPathExpression>] expression
        # @param [Hash<Shape Reference>] from The shape reference, typically
        #   an operation, to resolve the path starting from.
        # @return [String, nil] Returns the class name resolved, or `nil`
        #   if the path does not resolve in the model.
        def resolve(expression, from)
          ref = expression.scan(/\w+|\[.*?\]/).inject(from) do |ref, part|
            shape = @api['shapes'][ref['shape']]
            if part[0] == '['
              return nil unless shape['type'] == 'list'
              shape['member']
            else
              return nil unless shape['type'] == 'structure'
              return nil unless shape['members'][part]
              shape['members'][part]
            end
          end
          ref && ref['shape']
        end

      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
aws-sdk-resources-2.0.21.pre lib/aws-sdk-resources/validator/path_resolver.rb
aws-sdk-resources-2.0.20.pre lib/aws-sdk-resources/validator/path_resolver.rb
aws-sdk-resources-2.0.19.pre lib/aws-sdk-resources/validator/path_resolver.rb
aws-sdk-resources-2.0.18.pre lib/aws-sdk-resources/validator/path_resolver.rb
aws-sdk-resources-2.0.17.pre lib/aws-sdk-resources/validator/path_resolver.rb
aws-sdk-resources-2.0.16.pre lib/aws-sdk-resources/validator/path_resolver.rb
aws-sdk-resources-2.0.15.pre lib/aws-sdk-resources/validator/path_resolver.rb
aws-sdk-resources-2.0.14.pre lib/aws-sdk-resources/validator/path_resolver.rb
aws-sdk-resources-2.0.13.pre lib/aws-sdk-resources/validator/path_resolver.rb
aws-sdk-resources-2.0.12.pre lib/aws-sdk-resources/validator/path_resolver.rb
aws-sdk-resources-2.0.11.pre lib/aws-sdk-resources/validator/path_resolver.rb