Class: Linzer::Message::Adapter::NetHTTP::Response

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

Instance Method Summary collapse

Methods inherited from Abstract

#attached_request?, #field?, #request?, #response?

Constructor Details

#initialize(operation, **options) ⇒ Response

Returns a new instance of Response.



8
9
10
11
12
13
14
# File 'lib/linzer/message/adapter/net_http/response.rb', line 8

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

#[](field_name) ⇒ Object

XXX: this implementation is incomplete, e.g.: ;tr parameter is not supported yet



21
22
23
24
# File 'lib/linzer/message/adapter/net_http/response.rb', line 21

def [](field_name)
  return @operation.code.to_i if field_name == "@status"
  @operation[field_name]
end

#attach!(signature) ⇒ Object



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

def attach!(signature)
  signature.to_h.each { |h, v| @operation[h] = v }
  @operation
end

#headersObject



16
17
18
# File 'lib/linzer/message/adapter/net_http/response.rb', line 16

def headers
  @operation.each_header.to_h
end