Class: Alchemrest::ResponseCapturedHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/alchemrest/response_captured_handler.rb

Constant Summary collapse

LEGACY_ON_RESPONSE_CAPTURED_METHOD_DEFINITION_MESSAGE =
<<~MSG
  Defining Alchemrest.on_response_captured like

  `Alchemrest.on_response_captured { |data, response, request| ... }` is deprecated.

  Going forward, method defintions should take the form

  `Alchemrest.on_response_captured { |identifier:, result:| ... }`

  where identifier is a string that identifies the http method and endpoint the request was made to
  and result is an `Alchemrest::Result` object that contains the captured response data, or an Error
  instance.
MSG

Instance Method Summary collapse

Instance Method Details

#callObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/alchemrest/response_captured_handler.rb', line 21

def call
  return unless request.response_capture_enabled

  unless Alchemrest.on_response_captured
    default_capture_method
    return
  end

  case Alchemrest.on_response_captured.arity
    in 3
      legacy_capture_handler
    in 1
      Alchemrest.on_response_captured.call(identifier:, result: capture_pipeline_result)
  end
end