Module: Linzer::Message::Wrapper Private

Defined in:
lib/linzer/message/wrapper.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Handles wrapping HTTP messages with the appropriate adapter.

This module maintains a registry of adapter classes for different HTTP message types (Rack, Net::HTTP, etc.) and selects the correct one when wrapping a message.

Class Method Summary collapse

Class Method Details

.register_adapter(operation_class, adapter_class) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Registers a custom adapter for an HTTP message class.

Parameters:

  • operation_class (Class)

    The HTTP message class

  • adapter_class (Class)

    The adapter class to use



41
42
43
# File 'lib/linzer/message/wrapper.rb', line 41

def register_adapter(operation_class, adapter_class)
  adapters[operation_class] = adapter_class
end

.wrap(operation, **options) ⇒ Adapter::Abstract

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Wraps an HTTP message with the appropriate adapter.

Parameters:

  • operation (Object)

    The HTTP request or response object

  • options (Hash)

    Additional options (e.g., :attached_request)

Returns:

Raises:

  • (Error)

    If no suitable adapter is found



26
27
28
29
30
31
32
33
34
35
# File 'lib/linzer/message/wrapper.rb', line 26

def wrap(operation, **options)
  adapter_class = adapters[operation.class]

  if !adapter_class
    ancestor = find_ancestor(operation)
    fail_with_unsupported(operation) unless ancestor
  end

  (adapter_class || ancestor).new(operation, **options)
end