7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/objectsframework/object_handler.rb', line 7
def self.run_methods(request,response,context)
path = request.path
parts = path.split("/")
if(path == "/" && !context.config[:root].nil?)
klass = Object.const_get(context.config[:root]).new
puts "Finishing up"
finished(klass,request,response,context);
klass.set_instance_variables(request,response).send(request.request_method.downcase!+"_"+context.config[:index_method])
return
end
begin
klass = Object.const_get(parts[1].capitalize).new.set_instance_variables(request,response)
puts "Finishing up"
finished(klass,request,response,context);
if(parts[3].nil?)
if(path[path.length-1] == "/" || parts.length == 2)
klass.send(request.request_method.downcase!+"_index");
else
klass.send(request.request_method.downcase!+"_"+parts[2])
end
else
klass.send(request.request_method.downcase!+"_"+parts[2],parts[3..parts.length])
end
rescue Exception => e
response.status = 404
notfound_response(response,e)
end
end
|