Class: Linzer::Message::Adapter::Generic::Response Abstract
- 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.
Direct Known Subclasses
Instance Method Summary collapse
-
#attach!(signature) ⇒ Object
Attaches a signature to the response.
-
#header(name) ⇒ String?
Retrieves a header value by name.
-
#initialize(operation, **options) ⇒ Response
constructor
Creates a new response adapter.
Methods inherited from Abstract
#[], #attached_request?, #field?, #request?, #response?
Constructor Details
#initialize(operation, **options) ⇒ Response
Creates a new response adapter.
19 20 21 22 23 24 25 |
# File 'lib/linzer/message/adapter/generic/response.rb', line 19 def initialize(operation, **) @operation = operation attached_request = [:attached_request] @attached_request = attached_request ? Message.new(attached_request) : nil validate_attached_request @attached_request if @attached_request freeze end |
Instance Method Details
#attach!(signature) ⇒ Object
Attaches a signature to the response.
37 38 39 40 |
# File 'lib/linzer/message/adapter/generic/response.rb', line 37 def attach!(signature) signature.to_h.each { |h, v| @operation[h] = v } @operation end |
#header(name) ⇒ String?
Retrieves a header value by name.
30 31 32 |
# File 'lib/linzer/message/adapter/generic/response.rb', line 30 def header(name) @operation[name] end |