auto_api 0.0.6 → 0.0.7
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 +4 -4
- data/lib/auto_api/base.rb +5 -3
- data/lib/auto_api/version.rb +1 -1
- 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: 1488bc482980f3a3028880513276ef611a421649
|
|
4
|
+
data.tar.gz: 3cf1da397d241f5f14d16924474c0782735d7f80
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8b41989ebc1540594485a7b1e4570a775cac022ebe04db706dc4a5e9c886d66581a35ec27ad1f2dc74b9ffa49f5a3f5a7f1ef2f8dec90f57f93e4fd9d4b21667
|
|
7
|
+
data.tar.gz: fc50cfab3fb0c2fbbfb549eabec716a4f0ca85b85a920aa2b6a1e1b5bf75f3dcd0353f2948f602cd9f54c2b0826971c02094db88b38fdde018fdacf6b6de722c
|
data/lib/auto_api/base.rb
CHANGED
|
@@ -10,6 +10,8 @@ class AutoApi::Base < Sinatra::Base
|
|
|
10
10
|
register Sinatra::Reloader
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
disable :protection
|
|
14
|
+
|
|
13
15
|
Mongoid.load!('./config/mongoid.yml')
|
|
14
16
|
|
|
15
17
|
# WE ARE RETURNING JSON
|
|
@@ -43,7 +45,7 @@ class AutoApi::Base < Sinatra::Base
|
|
|
43
45
|
|
|
44
46
|
post '/:resource/?' do |resource|
|
|
45
47
|
webtry do
|
|
46
|
-
resource = @resource.new(request.
|
|
48
|
+
resource = @resource.new(JSON.parse request.body.read)
|
|
47
49
|
resource.save!
|
|
48
50
|
json resource
|
|
49
51
|
end
|
|
@@ -52,7 +54,7 @@ class AutoApi::Base < Sinatra::Base
|
|
|
52
54
|
put '/:resource/:id/?' do |resource, id|
|
|
53
55
|
webtry do
|
|
54
56
|
resource = @resource.find(id)
|
|
55
|
-
resource.update_attributes!(request.
|
|
57
|
+
resource.update_attributes!(JSON.parse request.body.read)
|
|
56
58
|
end
|
|
57
59
|
end
|
|
58
60
|
|
|
@@ -72,7 +74,7 @@ class AutoApi::Base < Sinatra::Base
|
|
|
72
74
|
post '/:resource1/:id1/:resource2/?' do |_resource1, id1, resource2|
|
|
73
75
|
webtry do
|
|
74
76
|
parent_resource = @resource1.find(id1)
|
|
75
|
-
child_resource = @resource2.new(request.
|
|
77
|
+
child_resource = @resource2.new(JSON.parse request.body.read)
|
|
76
78
|
child_resource.save!
|
|
77
79
|
parent_resource.send(resource2) << child_resource
|
|
78
80
|
json child_resource
|
data/lib/auto_api/version.rb
CHANGED