Class: Typhoeus::Response
- Inherits:
-
Object
- Object
- Typhoeus::Response
- Defined in:
- lib/labclient/http.rb
Overview
Add Data : OJ Parsing
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
64 65 66 |
# File 'lib/labclient/http.rb', line 64 def path @path end |
Instance Method Details
#data ⇒ Object
66 67 68 69 70 |
# File 'lib/labclient/http.rb', line 66 def data return @data if @data @data = process_body end |
#friendly_error ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/labclient/http.rb', line 82 def friendly_error = if data data[:message] || data[:error] || data else end "#{code} - #{}" end |
#inspect ⇒ Object
60 61 62 |
# File 'lib/labclient/http.rb', line 60 def inspect "#<TyphoeusResponse code: #{code}>" end |
#process_body ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/labclient/http.rb', line 72 def process_body if body.empty? nil elsif headers['content-type'] == 'text/plain' body else Oj.load(body, mode: :compat, object_class: OpenStruct) end end |