Class: RackStep::Controller
- Inherits:
-
Object
- Object
- RackStep::Controller
- Defined in:
- lib/controller.rb
Overview
Abstract controller class with some helper methods. ALL your controllers MUST use this one as a superclass.
Direct Known Subclasses
Defined Under Namespace
Modules: BasicHttpAuthentication, ErbRendering
Instance Attribute Summary collapse
-
#request ⇒ Object
The request will be injected here.
-
#response ⇒ Object
The Rack::Response object that will be delivered to the user.
Instance Method Summary collapse
-
#after ⇒ Object
RackStep will always execute this method after processing the request of to the specified controller.
-
#before ⇒ Object
RackStep will always execute this method before delegating the request processing to the specified controller.
-
#initialize ⇒ Controller
constructor
A new instance of Controller.
-
#process_request ⇒ Object
Once the application receives a new request, the router will decide wich controller should process that request and will execute this method for the chosen controller.
Constructor Details
#initialize ⇒ Controller
Returns a new instance of Controller.
12 13 14 15 16 17 |
# File 'lib/controller.rb', line 12 def initialize @response = RackStep::Response.new @response.body = '' @response.content_type = 'application/json' @response.status = 200 end |
Instance Attribute Details
#request ⇒ Object
The request will be injected here.
7 8 9 |
# File 'lib/controller.rb', line 7 def request @request end |
#response ⇒ Object
The Rack::Response object that will be delivered to the user.
10 11 12 |
# File 'lib/controller.rb', line 10 def response @response end |
Instance Method Details
#after ⇒ Object
RackStep will always execute this method after processing the request of to the specified controller. The user may overwrite this method. This can be used to check for logging or any piece of code that must be executed after every request for this controller. This may be usefull if the user wants to create an abstract controllers. TODO: Is this really necessary?
40 41 |
# File 'lib/controller.rb', line 40 def after end |
#before ⇒ Object
RackStep will always execute this method before delegating the request processing to the specified controller. The user may overwrite this method. This may be usefull if the user wants to create an abstract controllers. TODO: Is this really necessary?
31 32 |
# File 'lib/controller.rb', line 31 def before end |
#process_request ⇒ Object
Once the application receives a new request, the router will decide wich controller should process that request and will execute this method for the chosen controller. So this is the most important method of this class and every controller should overwrite it to implement it’s business logic.
24 25 |
# File 'lib/controller.rb', line 24 def process_request end |