Sha256: 98ed3c0760c25b4e48b5192a66051f2fc3bb835e3b3508c0131e9d9ffc91384b

Contents?: true

Size: 899 Bytes

Versions: 28

Compression:

Stored size: 899 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] = nil
          end
        end
      end

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

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
aws-sdk-core-3.6.0 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.5.0 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.4.0 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.3.1 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.3.0 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.2.1 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.2.0 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.1.0 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.0.0 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.0.0.rc20 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.0.0.rc19 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.0.0.rc18 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.0.0.rc17 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.0.0.rc16 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.0.0.rc15 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.0.0.rc14 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.0.0.rc13 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.0.0.rc12 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.0.0.rc11 lib/aws-sdk-core/stubbing/stub_data.rb
aws-sdk-core-3.0.0.rc10 lib/aws-sdk-core/stubbing/stub_data.rb