class Rulers::Application

Public Instance Methods

call(env) click to toggle source
# File lib/rulers.rb, line 11
def call(env)
  if env['PATH_INFO'] == 'favicon.ico'
    return [404,
      {'Content-Type' => 'text/html'}, []]
  end
  if env['PATH_INFO'] == '/'
    return [302,
    {"Location" => "/home/index"}, []]
  end
  klass, act = get_controller_and_action(env)
  controller = klass.new(env)
  text = controller.send(act)
  [200, {'Content-Type' => 'text/html'},
    [text]]
end
get_controller_and_action(env) click to toggle source
# File lib/rulers/routing.rb, line 3
def get_controller_and_action(env)
  _, cont, action, after =
  env["PATH_INFO"].split('/', 4)
  cont = cont.capitalize # "People"
  cont += "Controller" # "PeopleController"

  [Object.const_get(cont), action]
end