Class: Rack::Client::Simple::CollapsedResponse

Inherits:
Response
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/rack/client/adapter/simple.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Response

#each, #load_body

Constructor Details

#initialize(*tuple) ⇒ CollapsedResponse

Returns a new instance of CollapsedResponse.



40
41
42
# File 'lib/rack/client/adapter/simple.rb', line 40

def initialize(*tuple)
  @response, @body = Response.new(*tuple), nil
end

Instance Attribute Details

#responseObject

Returns the value of attribute response.



33
34
35
# File 'lib/rack/client/adapter/simple.rb', line 33

def response
  @response
end

Instance Method Details

#bodyObject



44
45
46
47
# File 'lib/rack/client/adapter/simple.rb', line 44

def body
  collapse! unless @body
  @body
end

#collapse!Object



49
50
51
52
53
# File 'lib/rack/client/adapter/simple.rb', line 49

def collapse!
  @body = ''
  each {|chunk| @body << chunk }
  @body
end