lib/hyper_resource/modules/http.rb in hyperresource-0.1.3 vs lib/hyper_resource/modules/http.rb in hyperresource-0.1.9
- old
+ new
@@ -28,22 +28,24 @@
end
private
def finish_up
+ self.loaded = true
+ self.response_object = self.adapter.deserialize(self.response.body)
+ self.adapter.apply(self.response_object, self)
+
status = self.response.status
if status / 100 == 2
- self.response_body = JSON.parse(self.response.body)
- self.init_from_response_body!
- self.blessed
+ return self.to_response_class
elsif status / 100 == 3
## TODO redirect logic?
elsif status / 100 == 4
raise HyperResource::ClientError, status.to_s
elsif status / 100 == 5
raise HyperResource::ServerError, status.to_s
else ## 1xx? really?
- raise HyperResource::Exception, "Got status #{status}, wtf?"
+ raise HyperResource::ResponseError, "Got status #{status}, wtf?"
end
end
end