class RackStep::App
Abstract class with the base of a RackStep
app. This class MUST be extended by the user.
Attributes
Stores the received request which will then be injected into the user controllers.
Public Class Methods
Source
# File lib/rackstep.rb, line 63 def self.add_route(verb, path, controller) router = Router.instance router.add_route(verb, path, controller) end
This method was created to make it easier for the user to add routes, but it will delegate to the router singleton class.
Source
# File lib/rackstep.rb, line 29 def self.call(env) response = new(env).process_request return response.status, response.headers, response.body end
Static method called from config.ru (“run App”).
Source
# File lib/rackstep.rb, line 35 def initialize(env) @request = Rack::Request.new(env) # Adding default routes to handle page not found (404). router.add_route_for_all_verbs('notfound', RackStep::NotFoundController) end
Initialize the request instance variable and add a default “not found” route.
Public Instance Methods
Source
# File lib/rackstep.rb, line 43 def process_request verb = request.request_method path = request.path # In RackStep, each request is processed by a controller. The router # is responsable to find, based on the given path and http verb, # the apropriate controller to handle the request. route = router.find_route_for(path, verb) controller = route.controller.new controller.request = request controller.send(:before) controller.send(:process_request) controller.send(:after) response = controller.response return response end
TODO: Code Climate says this method is too big.