Sha256: e2310161d6950d479fe40446f32ebe545811167f617dae2596e71621f1d42381

Contents?: true

Size: 840 Bytes

Versions: 9

Compression:

Stored size: 840 Bytes

Contents

# frozen_string_literal: true

module Aws
  module Endpoints
    # @api private
    class Condition
      def initialize(fn:, argv:, assign: nil)
        @fn = Function.new(fn: fn, argv: argv)
        @assign = assign
        @assigned = {}
      end

      attr_reader :fn
      attr_reader :argv
      attr_reader :assign

      attr_reader :assigned

      def match?(parameters, assigns)
        output = @fn.call(parameters, assigns)
        @assigned = @assigned.merge({ @assign => output }) if @assign
        output
      end

      def self.from_json(conditions_json)
        conditions_json.each.with_object([]) do |condition, conditions|
          conditions << new(
            fn: condition['fn'],
            argv: condition['argv'],
            assign: condition['assign']
          )
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
aws-sdk-core-3.168.4 lib/aws-sdk-core/endpoints/condition.rb
aws-sdk-core-3.168.3 lib/aws-sdk-core/endpoints/condition.rb
aws-sdk-core-3.168.2 lib/aws-sdk-core/endpoints/condition.rb
aws-sdk-core-3.168.1 lib/aws-sdk-core/endpoints/condition.rb
aws-sdk-core-3.168.0 lib/aws-sdk-core/endpoints/condition.rb
aws-sdk-core-3.167.0 lib/aws-sdk-core/endpoints/condition.rb
aws-sdk-core-3.166.0 lib/aws-sdk-core/endpoints/condition.rb
aws-sdk-core-3.165.1 lib/aws-sdk-core/endpoints/condition.rb
aws-sdk-core-3.165.0 lib/aws-sdk-core/endpoints/condition.rb