rubapi 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubapi/controller.rb +28 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f80b8e96bec40c2a7c6387864e9ec04a81d95bac
|
4
|
+
data.tar.gz: 86323cc0ce6788ac329f80430588c097c8100f6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e29fa72ced6467304b78573ae5e866878b31ff5fa03dc5598e7f78fa529bd02e08e6b7b66fd972d71a3bcce4aaf50cfa0ffe19d941e06138c821a0d67941e98d
|
7
|
+
data.tar.gz: 721678a8a5c297226783aa4630b82c2c3b7cb39a774954f07f8a8a8fb81c21cd8adb41db19704cfe15fddfcdcd984fe3c5d68ed570a10eed3b84de3e3be380f3
|
data/lib/rubapi/controller.rb
CHANGED
@@ -7,37 +7,39 @@ module Rubapi
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def index
|
10
|
+
not_defined
|
10
11
|
end
|
11
12
|
|
12
13
|
def show
|
14
|
+
not_defined
|
13
15
|
end
|
14
16
|
|
15
17
|
def create
|
18
|
+
not_defined
|
16
19
|
end
|
17
20
|
|
18
21
|
def update
|
22
|
+
not_defined
|
19
23
|
end
|
20
24
|
|
21
25
|
def delete
|
26
|
+
not_defined
|
22
27
|
end
|
23
28
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
return response
|
29
|
+
def not_defined
|
30
|
+
self.response.tap do |r|
|
31
|
+
r.status = 417
|
32
|
+
r.content = "{\"errors\":[\"not defined\"]}"
|
33
|
+
r.send_response
|
30
34
|
end
|
35
|
+
end
|
31
36
|
|
32
|
-
|
33
|
-
|
34
|
-
controller.params = self.params
|
35
|
-
|
36
|
-
response.tap do |r|
|
37
|
+
def send_response(content)
|
38
|
+
self.response.tap do |r|
|
37
39
|
r.status = 200
|
38
40
|
|
39
41
|
begin
|
40
|
-
r.content = JSON.generate(
|
42
|
+
r.content = JSON.generate(content)
|
41
43
|
rescue
|
42
44
|
r.content = "{\"errors\":[\"can't generate a json object\"]}"
|
43
45
|
r.status = 417 #Execution failed
|
@@ -46,5 +48,19 @@ module Rubapi
|
|
46
48
|
end
|
47
49
|
end
|
48
50
|
end
|
51
|
+
|
52
|
+
def run(route)
|
53
|
+
if route.nil?
|
54
|
+
response.status = 404
|
55
|
+
response.send_response
|
56
|
+
|
57
|
+
return response
|
58
|
+
end
|
59
|
+
|
60
|
+
route[:controller] ||= self.class
|
61
|
+
controller = route[:controller].new(self.response)
|
62
|
+
controller.params = self.params
|
63
|
+
controller.send(route[:method])
|
64
|
+
end
|
49
65
|
end
|
50
66
|
end
|