Sha256: 5031ed276a536c297753dcedd88665f6fc5e318b9da780bf2fd92656b546a483

Contents?: true

Size: 1.05 KB

Versions: 997

Compression:

Stored size: 1.05 KB

Contents

module Aws
  module Rest
    module Response
      class Body

        include Seahorse::Model::Shapes

        # @param [Class] parser_class
        # @param [Seahorse::Model::ShapeRef] rules
        def initialize(parser_class, rules)
          @parser_class = parser_class
          @rules = rules
        end

        # @param [IO] body
        # @param [Hash, Struct] data
        def apply(body, data)
          if streaming?
            data[@rules[:payload]] = body
          elsif @rules[:payload]
            data[@rules[:payload]] = parse(body.read, @rules[:payload_member])
          elsif !@rules.shape.member_names.empty?
            parse(body.read, @rules, data)
          end
        end

        private

        def streaming?
          @rules[:payload] && (
            BlobShape === @rules[:payload_member].shape ||
            StringShape === @rules[:payload_member].shape
          )
        end

        def parse(body, rules, target = nil)
          @parser_class.new(rules).parse(body, target) if body.size > 0
        end

      end
    end
  end
end

Version data entries

997 entries across 997 versions & 2 rubygems

Version Path
aws-sdk-core-2.11.632 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.631 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.630 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.629 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.628 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.627 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.626 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.625 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.624 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.623 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.622 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.621 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.620 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.619 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.618 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.617 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.616 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.615 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.614 lib/aws-sdk-core/rest/response/body.rb
aws-sdk-core-2.11.613 lib/aws-sdk-core/rest/response/body.rb