objectsframework 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 429369f2c81c72bafc6dff2fb30225fb2566b7b5
4
- data.tar.gz: b1fb16aa56a1aaea7167e6ac88de2ccc54472533
3
+ metadata.gz: 30d61999b7e0f96d7258ea7a09db0475b8332e37
4
+ data.tar.gz: c9e4114b40d67cf9b1ac9f18c1deb58dff94a882
5
5
  SHA512:
6
- metadata.gz: 9b1c20dbf8d004588b66b9c67627d47a5999808e7107aade1f4e83ed46dcbd7e2626a4100823866b0826c9e77e77fc063f4b71e501d22b4eb89722cde5ce23e5
7
- data.tar.gz: e4615b752e84173283c35ac8623c882aa21d00e2c3be60d600dd63fee4f5bb99d9c8e510b03685368ccc2acc93112180cea728fb31b5254526e10fab1c4b7063
6
+ metadata.gz: e47f0a245ebbe00360aded3834c55991dccba29ad5ecce554686c17c00a37e16084e592bda6ea9403ee96f8b79614c34cae42e21ec5e90691c0cf861df5c4f5f
7
+ data.tar.gz: 762c135d8f7aafc5cbb6f6ac571bfa1abcd8b96a7d5eda50650c44daa686559a32eeb2e37bfce8c4810bc404340c74727b98a5e12b66914c9180bad84156ab3b
@@ -1,12 +1,17 @@
1
1
  module ObjectsFramework
2
2
  class ObjectHandler
3
- def self.run_methods(request,response)
3
+ def self.run_methods(request,response,context)
4
4
  path = request.path
5
5
  parts = path.split("/")
6
+ if(path == "/" && !context.config[:root].nil?)
7
+ klass = Object.const_get(context.config[:root]).new.set_instance_variables(request,response).send(request.request_method.downcase!+"_"+context.config[:index_method])
8
+ return
9
+ end
10
+
6
11
  begin
7
12
  klass = Object.const_get(parts[1].capitalize).new.set_instance_variables(request,response)
8
- if(parts[3].nil?)
9
- if(path[path.length-1] == "/")
13
+ if(parts[3].nil?)
14
+ if(path[path.length-1] == "/" || parts.length == 2)
10
15
  klass.send(request.request_method.downcase!+"_index");
11
16
  else
12
17
  klass.send(request.request_method.downcase!+"_"+parts[2])
@@ -1,7 +1,9 @@
1
1
  module ObjectsFramework
2
2
  class Server
3
- def initialize
3
+ attr_accessor :config
4
4
 
5
+ def initialize(config = {})
6
+ @config = {:index_method => "index"}.merge(config)
5
7
  end
6
8
 
7
9
  def call(env)
@@ -12,7 +14,7 @@ module ObjectsFramework
12
14
  response.length = 0
13
15
  # Set text/html as Content-type by default
14
16
  response.header["Content-type"] = "text/html"
15
- ObjectsFramework::ObjectHandler.run_methods(request,response);
17
+ ObjectsFramework::ObjectHandler.run_methods(request,response,self);
16
18
  response.finish
17
19
  end
18
20
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: objectsframework
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bram Vandenbogaerde
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-04 00:00:00.000000000 Z
11
+ date: 2015-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack