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
45
46
47
48
49
50
51
52
# 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
        self.http_response=(response)
      end
    end

    def http_response
      http_storage[:ActiveResourceResponse]
    end

    def http_response=(response)
      http_storage[:ActiveResourceResponse] = response
    end

    def http_storage
      Thread.current
    end
  end
end