Class: Linzer::Message::Adapter::Generic::Response Abstract

Inherits:
Abstract
  • Object
show all
Defined in:
lib/linzer/message/adapter/generic/response.rb

Overview

This class is abstract.

Subclass must implement #derived method.

Generic HTTP response adapter.

Provides a base implementation for response message access. Assumes the operation responds to ‘[]` for header access.

Instance Method Summary collapse

Methods inherited from Abstract

#[], #attach!, #attached_request?, #field?, #has_signature?, #request?, #response?

Constructor Details

#initialize(operation, **options) ⇒ Response

Creates a new response adapter.

Parameters:

  • operation (Object)

    The HTTP response object

  • options (Hash)

    Additional options

Options Hash (**options):

  • :attached_request (Object)

    An associated request for ‘;req` parameter support



19
20
21
22
23
24
25
# File 'lib/linzer/message/adapter/generic/response.rb', line 19

def initialize(operation, **options)
  @operation = operation
  attached_request = options[:attached_request]
  @attached_request = attached_request ? Message.new(attached_request) : nil
  validate_attached_request @attached_request if @attached_request
  freeze
end

Instance Method Details

#header(name) ⇒ String?

Retrieves a header value by name.

Parameters:

  • name (String)

    The header name

Returns:

  • (String, nil)

    The header value



30
31
32
# File 'lib/linzer/message/adapter/generic/response.rb', line 30

def header(name)
  @operation[name]
end