Sha256: 6a6d0bc9f15fac1f87caae6d1c2ed0568102aab908c8e02ab32bceb04af7bc05

Contents?: true

Size: 916 Bytes

Versions: 12

Compression:

Stored size: 916 Bytes

Contents

module Aws
  # @api private
  module Stubbing
    class StubData

      def initialize(operation)
        @rules = operation.output
        @pager = operation[:pager]
      end

      def stub(data = {})
        stub = EmptyStub.new(@rules).stub
        remove_paging_tokens(stub)
        apply_data(data, stub)
        stub
      end

      private

      def remove_paging_tokens(stub)
        if @pager
          @pager.instance_variable_get("@tokens").keys.each do |path|
            key = path.split(/\b/)[0]
            stub[key] = nil
          end
          if more_results = @pager.instance_variable_get('@more_results')
            stub[more_results] = false
          end
        end
      end

      def apply_data(data, stub)
        ParamValidator.new(@rules, validate_required: false, input: false).validate!(data)
        DataApplicator.new(@rules).apply_data(data, stub)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
aws-sdk-core-3.52.0 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.51.0 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.50.0 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.49.0 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.48.6 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.48.5 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.48.4 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.48.3 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.48.2 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.48.1 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.48.0 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.47.0 lib/aws-sdk-core/stubbing/stub_data.rb