Sha256: 906d173e754cda59b64ae8acb7be8b518935db1ae47f704957c8d19a9995422e

Contents?: true

Size: 1.3 KB

Versions: 84

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

module Aws
  module Endpoints
    # This class is deprecated. It is used by the Runtime endpoint
    # resolution approach. It has been replaced by a code generated
    # approach in each service gem. It can be removed in a new
    # major version. It has to exist because
    # old service gems can use a new core version.
    # @api private
    class TreeRule
      def initialize(type: 'tree', conditions:, rules:, documentation: nil)
        @type = type
        @conditions = Condition.from_json(conditions)
        @rules = RuleSet.rules_from_json(rules)
        @documentation = documentation
      end

      attr_reader :type
      attr_reader :conditions
      attr_reader :error
      attr_reader :documentation

      def match(parameters, assigned = {})
        assigns = assigned.dup
        matched = conditions.all? do |condition|
          output = condition.match?(parameters, assigns)
          assigns = assigns.merge(condition.assigned) if condition.assign
          output
        end
        resolve_rules(parameters, assigns) if matched
      end

      private

      def resolve_rules(parameters, assigns)
        @rules.each do |rule|
          output = rule.match(parameters, assigns)
          return output if output
        end
        nil
      end
    end
  end
end

Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
aws-sdk-core-3.202.2 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.202.1 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.202.0 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.201.5 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.201.4 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.201.3 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.201.2 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.201.1 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.201.0 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.200.0 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.199.0 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.198.0 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.197.2 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.197.1 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.197.0 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.194.1 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.194.0 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.193.0 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.192.1 lib/aws-sdk-core/endpoints/tree_rule.rb
aws-sdk-core-3.192.0 lib/aws-sdk-core/endpoints/tree_rule.rb