Class: Debugbar::HttpResponse
- Inherits:
-
Object
- Object
- Debugbar::HttpResponse
- Defined in:
- lib/debugbar/http/http.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status, headers, body) ⇒ HttpResponse
constructor
A new instance of HttpResponse.
- #to_h ⇒ Object
Constructor Details
#initialize(status, headers, body) ⇒ HttpResponse
Returns a new instance of HttpResponse.
28 29 30 31 32 |
# File 'lib/debugbar/http/http.rb', line 28 def initialize(status, headers, body) @status = status @headers = headers @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
26 27 28 |
# File 'lib/debugbar/http/http.rb', line 26 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
26 27 28 |
# File 'lib/debugbar/http/http.rb', line 26 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
26 27 28 |
# File 'lib/debugbar/http/http.rb', line 26 def status @status end |
Class Method Details
.from_rack(rack_res) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/debugbar/http/http.rb', line 34 def self.from_rack(rack_res) return nil if rack_res.nil? headers = rack_res.headers.to_h.transform_keys { |s| s.split('-').map(&:capitalize).join('-') } new(rack_res.status, headers, rack_res.body) end |
Instance Method Details
#to_h ⇒ Object
42 43 44 |
# File 'lib/debugbar/http/http.rb', line 42 def to_h { status:, headers:, body: } end |