Class: Faraday::Response
- 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.
Constructor Details
#initialize(headers = nil, body = nil) ⇒ Response
Returns a new instance of Response.
12 13 14 15 16 17 18 |
# File 'lib/faraday/response.rb', line 12 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.
22 23 24 25 26 27 |
# File 'lib/faraday/response.rb', line 22 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.
30 31 32 33 |
# File 'lib/faraday/response.rb', line 30 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.
37 38 39 |
# File 'lib/faraday/response.rb', line 37 def processed! self.body = body.join if body.respond_to?(:join) end |