Class: Linzer::Message::Adapter::Rack::Response

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

Overview

Adapter for Rack::Response objects.

Instance Method Summary collapse

Methods inherited from Abstract

#[], #attached_request?, #field?, #request?, #response?

Constructor Details

#initialize(operation, **options) ⇒ Response

Creates a new Rack response adapter.

Options Hash (**options):

  • :attached_request (Object)

    Request for ‘;req` support



15
16
17
18
19
20
21
22
# File 'lib/linzer/message/adapter/rack/response.rb', line 15

def initialize(operation, **options)
  @operation = operation
  validate
  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

#attach!(signature) ⇒ ::Rack::Response

Attaches a signature to the response.



34
35
36
37
38
39
# File 'lib/linzer/message/adapter/rack/response.rb', line 34

def attach!(signature)
  signature.to_h.each do |h, v|
    @operation.set_header(h, v)
  end
  @operation
end

#header(name) ⇒ String?

Retrieves a header value by name.



27
28
29
# File 'lib/linzer/message/adapter/rack/response.rb', line 27

def header(name)
  @operation.get_header(name)
end