Class: ObjectsFramework::Server

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Server

Returns a new instance of Server.



5
6
7
# File 'lib/objectsframework/server.rb', line 5

def initialize(config = {})
  @config = {:index_method => "index"}.merge(config)
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



3
4
5
# File 'lib/objectsframework/server.rb', line 3

def config
  @config
end

#envObject

Returns the value of attribute env.



3
4
5
# File 'lib/objectsframework/server.rb', line 3

def env
  @env
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/objectsframework/server.rb', line 9

def call(env)
  @env = env
  request = Rack::Request.new(env)
  response = Rack::Response.new(env)
  # Solves some weird bug where ENV is added to the response body
  response.body = []
  response.length = 0
  # Set text/html as Content-type by default
  response.header["Content-type"] = "text/html"
  handler = ObjectsFramework::ObjectHandler.run_methods(request,response,self)
  if(handler === true)
    response.finish
  else
    return handler
  end
end