dscout/fragmenter

View on GitHub
lib/fragmenter/request.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Fragmenter
  class Request
    attr_accessor :fragmenter, :headers, :resource

    def initialize(options = {})
      @body       = options.fetch(:body, StringIO.new(''))
      @fragmenter = options.fetch(:fragmenter, nil)
      @headers    = options.fetch(:headers, {})
      @resource   = options.fetch(:resource, nil)
    end

    def body
      if @body.respond_to?(:read)
        @body.read.tap { |_| @body.rewind }
      else
        @body
      end
    end
  end
end