Module: VCR::LibraryHooks::WebMock

Extended by:
WebMock, Helpers
Included in:
WebMock
Defined in:
lib/vcr/library_hooks/webmock.rb

Defined Under Namespace

Modules: Helpers Classes: RequestHandler

Instance Method Summary collapse

Methods included from Helpers

request_headers_for, typed_request_for, vcr_request_for, vcr_response_for

Instance Method Details

#global_hook_disabled?(request) ⇒ Boolean

Returns:

  • (Boolean)

27
28
29
30
# File 'lib/vcr/library_hooks/webmock.rb', line 27

def global_hook_disabled?(request)
  requests = @global_hook_disabled_requests[Thread.current.object_id]
  requests && requests.include?(request)
end

#global_hook_disabled_requestsObject


32
33
34
35
36
37
38
39
40
41
# File 'lib/vcr/library_hooks/webmock.rb', line 32

def global_hook_disabled_requests
  requests = @global_hook_disabled_requests[Thread.current.object_id]
  return requests if requests

  ObjectSpace.define_finalizer(Thread.current, lambda {
    @global_hook_disabled_requests.delete(Thread.current.object_id)
  })

  @global_hook_disabled_requests[Thread.current.object_id] = []
end

#with_global_hook_disabled(request) ⇒ Object


17
18
19
20
21
22
23
24
25
# File 'lib/vcr/library_hooks/webmock.rb', line 17

def with_global_hook_disabled(request)
  global_hook_disabled_requests << request

  begin
    yield
  ensure
    global_hook_disabled_requests.delete(request)
  end
end