class RackStep::Controller

Abstract controller class with some helper methods. ALL your controllers MUST use this one as a superclass.

Attributes

request[RW]

The request will be injected here.

response[RW]

The Rack::Response object that will be delivered to the user.

Public Class Methods

new() click to toggle source
# File lib/controller.rb, line 12
def initialize
  @response = RackStep::Response.new
  @response.body = ''
  @response.content_type = 'application/json'
  @response.status = 200
end

Public Instance Methods

after() click to toggle source

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?

# File lib/controller.rb, line 40
def after
end
before() click to toggle source

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?

# File lib/controller.rb, line 31
def before
end
process_request() click to toggle source

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.

# File lib/controller.rb, line 24
def process_request
end