Class: WebConsole::Response
- Inherits:
-
Struct
- Object
- Struct
- WebConsole::Response
- Defined in:
- lib/web_console/response.rb
Overview
A response object that writes content before the closing </body> tag, if possible.
The object quacks like Rack::Response.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
8 9 10 |
# File 'lib/web_console/response.rb', line 8 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers
8 9 10 |
# File 'lib/web_console/response.rb', line 8 def headers @headers end |
#status ⇒ Object
Returns the value of attribute status
8 9 10 |
# File 'lib/web_console/response.rb', line 8 def status @status end |
Instance Method Details
#finish ⇒ Object
23 24 25 |
# File 'lib/web_console/response.rb', line 23 def finish Rack::Response.new(body, status, headers).finish end |
#write(content) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/web_console/response.rb', line 9 def write(content) raw_body = Array(body).first.to_s # We're done with the original body object, so make sure to close it to comply with the Rack SPEC body.close if body.respond_to?(:close) self.body = if position = raw_body.rindex("</body>") raw_body.dup.insert(position, content) else raw_body.dup << content end end |