Class: Faraday::Response
- Extended by:
- AutoloadHelper
- Defined in:
- lib/faraday/response.rb,
lib/faraday/response/yajl_response.rb
Direct Known Subclasses
Defined Under Namespace
Classes: YajlResponse
Class Attribute Summary collapse
-
.load_error ⇒ Object
Returns the value of attribute load_error.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(headers = nil, body = nil) ⇒ Response
constructor
A new instance of Response.
-
#process(chunk) ⇒ Object
TODO: process is a funky name.
-
#process!(full_body) ⇒ Object
Assume the given content is the full body, and not streamed.
-
#processed! ⇒ Object
Signals the end of streamed content.
Methods included from AutoloadHelper
Constructor Details
#initialize(headers = nil, body = nil) ⇒ Response
Returns a new instance of Response.
14 15 16 17 18 19 20 |
# File 'lib/faraday/response.rb', line 14 def initialize(headers = nil, body = nil) super(headers || {}, body) if block_given? yield self processed! end end |
Class Attribute Details
.load_error ⇒ Object
Returns the value of attribute load_error.
4 5 6 |
# File 'lib/faraday/response.rb', line 4 def load_error @load_error end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
2 3 4 |
# File 'lib/faraday/response.rb', line 2 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers
2 3 4 |
# File 'lib/faraday/response.rb', line 2 def headers @headers end |
Class Method Details
.loaded? ⇒ Boolean
5 6 7 |
# File 'lib/faraday/response.rb', line 5 def loaded? !load_error end |
Instance Method Details
#process(chunk) ⇒ Object
TODO: process is a funky name. change it processes a chunk of the streamed body.
24 25 26 27 28 29 |
# File 'lib/faraday/response.rb', line 24 def process(chunk) if !body self.body = [] end body << chunk end |
#process!(full_body) ⇒ Object
Assume the given content is the full body, and not streamed.
32 33 34 35 |
# File 'lib/faraday/response.rb', line 32 def process!(full_body) process(full_body) processed! end |
#processed! ⇒ Object
Signals the end of streamed content. Do whatever you need to clean up the streamed body.
39 40 41 |
# File 'lib/faraday/response.rb', line 39 def processed! self.body = body.join if body.respond_to?(:join) end |