Class: ObjectsFramework::ObjectHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/objectsframework/object_handler.rb

Class Method Summary collapse

Class Method Details

.run_methods(request, response) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/objectsframework/object_handler.rb', line 3

def self.run_methods(request,response)
  path = request.path
  parts = path.split("/")
  begin
    klass = Object.const_get(parts[1].capitalize).new.set_instance_variables(request,response)
    if(parts[3].nil?)
      if(path[path.length-1] == "/")
        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
    response.write "<h1>404 Not Found</h1><hr/><i>Ruby Rack Server powered by ObjectsFramework <br/><pre>#{e.to_s}</pre></i>"
  end

end