Class: HttpHelper::WebHttpResponse

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/helpers/tmc_helpers/http_helper/http_helper.rb

Overview

Adds json attribute to http response

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ WebHttpResponse

Returns a new instance of WebHttpResponse.



86
87
88
89
# File 'lib/helpers/tmc_helpers/http_helper/http_helper.rb', line 86

def initialize(http_response)
  super(http_response)
  @code = self.code.to_i
end

Instance Method Details

#jsonObject

Public: Gets response json, if any.

Returns a Hash of response json, or nil.



94
95
96
# File 'lib/helpers/tmc_helpers/http_helper/http_helper.rb', line 94

def json
  json_parse(self.body) rescue nil
end