Skip to content

Commit f8bfcdd

Browse files
committed
Add a helper returns the response body as a hash
1 parent 2b45ad9 commit f8bfcdd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/ruby_http_client.rb

Lines changed: 6 additions & 0 deletions
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)