lib/flexirest/request.rb in flexirest-1.5.7 vs lib/flexirest/request.rb in flexirest-1.5.8
- old
+ new
@@ -6,11 +6,11 @@
module Flexirest
class Request
include AttributeParsing
include JsonAPIProxy
- attr_accessor :post_params, :get_params, :url, :path, :headers, :method, :object, :body, :forced_url, :original_url
+ attr_accessor :post_params, :get_params, :url, :path, :headers, :method, :object, :body, :forced_url, :original_url, :retrying
def initialize(method, object, params = {})
@method = method
@method[:options] ||= {}
@method[:options][:lazy] ||= []
@@ -209,12 +209,19 @@
if object_is_class? && @object.record_response?
@object.record_response(self.url, response_env)
end
if object_is_class?
- @object.send(:_callback_request, :after, @method[:name], response_env)
+ callback_result = @object.send(:_callback_request, :after, @method[:name], response_env)
else
- @object.class.send(:_callback_request, :after, @method[:name], response_env)
+ callback_result = @object.class.send(:_callback_request, :after, @method[:name], response_env)
+ end
+
+ if callback_result == :retry
+ if self.retrying != true
+ self.retrying = true
+ return call()
+ end
end
result = handle_response(response_env, cached)
@response_delegate.__setobj__(result)
original_object_class.write_cached_response(self, response_env, result)