Module: ActiveResourceResponse::Connection

Defined in:
lib/active_resource_response/connection.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/active_resource_response/connection.rb', line 25

def self.included(base)
  base.class_eval do
    alias_method :origin_handle_response, :handle_response

    def handle_response(response)
      begin
        origin_handle_response(response)
      rescue
        raise
      ensure
        response.extend HttpResponse
        Thread.current[:ActiveResourceResponse] = response
      end
    end

    def http_response
      Thread.current[:ActiveResourceResponse]
    end
  end
end