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.



43
44
45
# File 'lib/linzer/message/wrapper.rb', line 43

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.

Raises:

  • (Error)

    If no suitable adapter is found



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

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