Class: FieldView::FieldViewResponse
- Inherits:
-
Object
- Object
- FieldView::FieldViewResponse
- Defined in:
- lib/fieldview/fieldview_response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#http_body ⇒ Object
Returns the value of attribute http_body.
-
#http_headers ⇒ Object
Returns the value of attribute http_headers.
-
#http_status ⇒ Object
Returns the value of attribute http_status.
-
#request_id ⇒ Object
Returns the value of attribute request_id.
Instance Method Summary collapse
-
#initialize(response) ⇒ FieldViewResponse
constructor
A new instance of FieldViewResponse.
Constructor Details
#initialize(response) ⇒ FieldViewResponse
Returns a new instance of FieldViewResponse.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fieldview/fieldview_response.rb', line 8 def initialize(response) self.http_headers = {} response.each_capitalized_name do |n| self.http_headers[n] = response[n] end self.http_body = response.body if response.body then begin self.data = JSON.parse(response.body, symbolize_names: true) rescue JSON::ParserError self.data = nil end else self.data = nil end self.http_status = response.code.to_i self.request_id = self.http_headers[FieldView::REQUEST_ID_HEADER_KEY] end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
7 8 9 |
# File 'lib/fieldview/fieldview_response.rb', line 7 def data @data end |
#http_body ⇒ Object
Returns the value of attribute http_body.
4 5 6 |
# File 'lib/fieldview/fieldview_response.rb', line 4 def http_body @http_body end |
#http_headers ⇒ Object
Returns the value of attribute http_headers.
5 6 7 |
# File 'lib/fieldview/fieldview_response.rb', line 5 def http_headers @http_headers end |
#http_status ⇒ Object
Returns the value of attribute http_status.
6 7 8 |
# File 'lib/fieldview/fieldview_response.rb', line 6 def http_status @http_status end |
#request_id ⇒ Object
Returns the value of attribute request_id.
3 4 5 |
# File 'lib/fieldview/fieldview_response.rb', line 3 def request_id @request_id end |