Skip to content

Commit 3403d25

Browse files
Merge pull request #12 from belfazt/add-a-method-to-return-the-parsed-response-9
Add a helper returns the response body as a hash
2 parents 2b45ad9 + f8bfcdd commit 3403d25

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/ruby_http_client.rb

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ def initialize(response)
1515
@body = response.body
1616
@headers = response.to_hash
1717
end
18+
19+
# Returns the body as a hash
20+
#
21+
def parsed_body
22+
@parsed_body ||= JSON.parse(@body, symbolize_names: true)
23+
end
1824
end
1925

2026
# A simple REST client.

0 commit comments

Comments
 (0)