From 36a8efe542e98dd3b16c352c2a007c4fb6c23221 Mon Sep 17 00:00:00 2001 From: Mark Maglana Date: Tue, 10 Sep 2013 01:31:25 -0700 Subject: [PATCH] Fixes #24 --- lib/aviator/core/response.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/aviator/core/response.rb b/lib/aviator/core/response.rb index 53a6088..a282a9c 100644 --- a/lib/aviator/core/response.rb +++ b/lib/aviator/core/response.rb @@ -2,12 +2,20 @@ module Aviator class Response + + def body + @body ||= if response.body.length > 0 + JSON.parse(response.body).with_indifferent_access + else + {} + end + + @body.dup + end + def method_missing(name, *args) case name - when :body - @body ||= JSON.parse(response.body).with_indifferent_access - @body.dup when :headers, :status response.send(name) when :request