class Matrack::Application

Attributes

router[R]

Public Class Methods

new() click to toggle source
# File lib/matrack.rb, line 7
def initialize
  @router = Router.new
end

Public Instance Methods

call(env) click to toggle source
# File lib/matrack.rb, line 11
def call(env)
  route = router.route_for(env)
  if route
    route.execute(env)
    response_handler(route)
  else
    controller = BaseController.new(env)
    body = controller.invalid_route
    [404, {}, [body]]
  end
end
response_handler(route) click to toggle source
# File lib/matrack.rb, line 23
def response_handler(route)
  controller = route.mat_controller
  if controller.response
    controller.response
  else
    controller.render(route.action)
  end
end