Class: Consul::Async::HttpResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/consul/async/json_endpoint.rb,
lib/consul/async/consul_endpoint.rb

Overview

Basic Encapsulation of HTTP response from Consul It supports empty responses to handle first call is an easy way

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http, override_nil_response = nil) ⇒ HttpResponse

Returns a new instance of HttpResponse.



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/consul/async/json_endpoint.rb', line 81

def initialize(http, override_nil_response = nil)
  if http.nil?
    @response_header = nil
    @response = override_nil_response
    @error = 'Not initialized yet'
  else
    @response_header = http.response_header.nil? ? nil : http.response_header.dup.freeze
    @response = http.response.nil? || http.response.empty? ? override_nil_response : http.response.dup.freeze
    @error = http.error.nil? ? nil : http.error.dup.freeze
  end
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



80
81
82
# File 'lib/consul/async/json_endpoint.rb', line 80

def error
  @error
end

#responseObject (readonly)

Returns the value of attribute response.



80
81
82
# File 'lib/consul/async/json_endpoint.rb', line 80

def response
  @response
end

#response_headerObject (readonly)

Returns the value of attribute response_header.



80
81
82
# File 'lib/consul/async/json_endpoint.rb', line 80

def response_header
  @response_header
end