Class: Exa::Internal::Transport::AsyncRequester::ResponseAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/exa/internal/transport/async_requester.rb

Overview

Wraps an Async::HTTP::Response to mimic Net::HTTP’s header API.

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ResponseAdapter



19
20
21
# File 'lib/exa/internal/transport/async_requester.rb', line 19

def initialize(response)
  @response = response
end

Instance Method Details

#[](key) ⇒ Object



30
31
32
33
# File 'lib/exa/internal/transport/async_requester.rb', line 30

def [](key)
  value = @response.headers[key]
  value.is_a?(Array) ? value.first : value
end

#each_headerObject



23
24
25
26
27
28
# File 'lib/exa/internal/transport/async_requester.rb', line 23

def each_header
  return enum_for(__method__) unless block_given?
  @response.headers.each do |key, value|
    Array(value).each { |v| yield(key, v) }
  end
end

#finishObject



35
36
37
# File 'lib/exa/internal/transport/async_requester.rb', line 35

def finish
  @response.finish
end