Module: ActiveResourceHttpMock::ActiveResource::HttpMockable

Defined in:
lib/active_resource_http_mock/active_resource/http_mockable.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/active_resource_http_mock/active_resource/http_mockable.rb', line 7

def self.included(base)
  base.class_eval do
    private

    def http
      if Thread.current[:httpmock]
        _http_with_mock_
      else
        _http_without_mock_
      end
    end

    def _http_with_mock_
      @http ||= ::ActiveResource::HttpMock.new(@site)
    end

    def _http_without_mock_
      configure_http(new_http)
    end
  end
end