Class: VCR::Middleware::Faraday::RequestHandler

Inherits:
RequestHandler show all
Defined in:
lib/vcr/middleware/faraday.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logger::Mixin

#log, #request_summary, #response_summary

Constructor Details

#initialize(app, env) ⇒ RequestHandler

Returns a new instance of RequestHandler.



37
38
39
40
# File 'lib/vcr/middleware/faraday.rb', line 37

def initialize(app, env)
  @app, @env = app, env
  @has_on_complete_hook = false
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



36
37
38
# File 'lib/vcr/middleware/faraday.rb', line 36

def app
  @app
end

#envObject (readonly)

Returns the value of attribute env.



36
37
38
# File 'lib/vcr/middleware/faraday.rb', line 36

def env
  @env
end

Instance Method Details

#handleObject



42
43
44
45
46
47
48
49
50
# File 'lib/vcr/middleware/faraday.rb', line 42

def handle
  # Faraday must be exlusive here in case another library hook is being used.
  # We don't want double recording/double playback.
  VCR.library_hooks.exclusive_hook = :faraday
  super
ensure
  response = defined?(@vcr_response) ? @vcr_response : nil
  invoke_after_request_hook(response) unless delay_finishing?
end