Class: Waves::Response
Overview
Waves::Response represents an HTTP response and has methods for constructing a response. These include setters for content_type
, content_length
, location
, and expires
headers. You may also set the headers directly using the [] operator. If you don’t find what you are looking for here, check the documentation for Rack::Response since many methods for this class are delegated to Rack::Response.
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
-
#finish ⇒ Object
Finish the response.
-
#initialize(request) ⇒ Response
constructor
Create a new response.
-
#method_missing(name, *args) ⇒ Object
Methods not explicitly defined by Waves::Response are delegated to Rack::Response.
-
#session ⇒ Object
Returns the sessions associated with the request, allowing you to set values within it.
Constructor Details
#initialize(request) ⇒ Response
Create a new response. Takes the request object. You shouldn’t need to call this directly.
12 13 14 15 |
# File 'lib/runtime/response.rb', line 12 def initialize( request ) @request = request @response = Rack::Response.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
Methods not explicitly defined by Waves::Response are delegated to Rack::Response. Check the Rack documentation for more informations
35 36 37 |
# File 'lib/runtime/response.rb', line 35 def method_missing(name,*args) @response.send(name,*args) end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
9 10 11 |
# File 'lib/runtime/response.rb', line 9 def request @request end |
Instance Method Details
#finish ⇒ Object
Finish the response. This will send the response back to the client, so you shouldn’t attempt to further modify the response once this method is called. You don’t usually need to call it yourself, since it is called by the dispatcher once request processing is finished.
31 |
# File 'lib/runtime/response.rb', line 31 def finish ; request.session.save ; @response.finish ; end |
#session ⇒ Object
Returns the sessions associated with the request, allowing you to set values within it. The session will be created if necessary and saved when the response is complete.
25 |
# File 'lib/runtime/response.rb', line 25 def session ; request.session ; end |