Class: Rollerblades::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/rollerblades.rb,
lib/rollerblades/routing.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/rollerblades.rb', line 8

def call(env)
	if env['PATH_INFO'] == '/favicon.ico'
	return [404, {'Content-Type' => 'text/html'}, []]
	end

	klass, act = get_controller_and_action(env)
	contoller = klass.new(env)
	text = contoller.send(act)
	[200, {'Content-Type' => 'text/html'}, [text]]
end

#get_controller_and_action(env) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/rollerblades/routing.rb', line 3

def get_controller_and_action(env)
	_, controller, action, after = env["PATH_INFO"].split('/', 4)
	controller = controller.capitalize
	controller += "Controller"

	[Object.const_get(controller), action]
end