Class: Requester::Response
- Inherits:
-
Object
- Object
- Requester::Response
- Defined in:
- lib/requester/response.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #json ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 15 16 17 |
# File 'lib/requester/response.rb', line 10 def initialize(response) @response = response @json = { status: response.status, body: JSON.parse(response.body), message: response. } end |
Class Method Details
.generate(response) ⇒ Object
6 7 8 |
# File 'lib/requester/response.rb', line 6 def self.generate(response) new(response).json end |
Instance Method Details
#json ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/requester/response.rb', line 19 def json @json.tap do |json| Requester::Config.additional_response_attributes.each do |attr| json[attr] = @response.public_send(attr) end end end |