roda-rest_api 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/roda/plugins/rest_api.rb +6 -4
- data/lib/roda/rest_api.rb +0 -4
- 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: 80e8b5e484fe53a1f4fb788f1b626588dd4267d6
|
4
|
+
data.tar.gz: 330493a7f67ce9f21f23622c9e7f6959d5ba68f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b131711f5a1d500221c2830f63eba6b2c79a0494a3ed365a4ec4fa1c0453115fa7bd58d153a48c4f91d17009eeb23fce675b4062b3c1618bd04ec3e638cb3c07
|
7
|
+
data.tar.gz: 526075155bf5c1662de80353a5826df7a44bf99e1a4dcf5cc82b0168150d554069d50dd098ad7ee67470cb5736fd35a02fd5a08b524ec38382e42e1a1062dee3
|
@@ -14,7 +14,8 @@ class Roda
|
|
14
14
|
|
15
15
|
class Resource
|
16
16
|
|
17
|
-
attr_reader :request, :path, :singleton, :content_type, :parent
|
17
|
+
attr_reader :request, :path, :singleton, :content_type, :parent
|
18
|
+
attr_accessor :captures
|
18
19
|
|
19
20
|
def initialize(path, request, parent, options={})
|
20
21
|
@request = request
|
@@ -24,10 +25,9 @@ class Roda
|
|
24
25
|
@primary_key = options.delete(:primary_key) || "id"
|
25
26
|
@parent_key = options.delete(:parent_key) || "parent_id"
|
26
27
|
@content_type = options.delete(:content_type) || APPLICATION_JSON
|
27
|
-
if parent
|
28
|
+
if parent
|
28
29
|
@parent = parent
|
29
30
|
@parent.routes!
|
30
|
-
@captures = @request.captures.dup
|
31
31
|
@path = [':d', @path].join('/') unless bare
|
32
32
|
end
|
33
33
|
end
|
@@ -73,9 +73,10 @@ class Roda
|
|
73
73
|
begin
|
74
74
|
args = method === :save ? JSON.parse(@request.body) : @request.GET
|
75
75
|
args.merge!(@primary_key => id) if id
|
76
|
-
args.merge!(@parent_key => @captures[0]) if @
|
76
|
+
args.merge!(@parent_key => @captures[0]) if @captures
|
77
77
|
self.send(method).call(args)
|
78
78
|
rescue StandardError => e
|
79
|
+
raise if ENV['RACK_ENV'] == 'development'
|
79
80
|
@request.response.status = method === :save ? 422 : 404
|
80
81
|
end
|
81
82
|
end
|
@@ -98,6 +99,7 @@ class Roda
|
|
98
99
|
def resource(path, options={})
|
99
100
|
@resource = Resource.new(path, self, @resource, options)
|
100
101
|
on(@resource.path, options) do
|
102
|
+
@resource.captures = captures.dup unless captures.empty?
|
101
103
|
yield @resource
|
102
104
|
@resource.routes!
|
103
105
|
response.status = 404
|
data/lib/roda/rest_api.rb
CHANGED