grape-nested_resources 0.2.1 → 0.3.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b542e342e88b34733252e8bef4120a5388934901
|
4
|
+
data.tar.gz: f9e4397b25734f8631dcff310439a29cc9a82b6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52d21bb61a1e499594d828839b03d753fd17c147c01246da3b29c6d407b190f6319e6c8e2716e2084b2b7d1b79a2cd0d5c27d51e70359d634810b014171fb029
|
7
|
+
data.tar.gz: 5452929fc853772848342b724def4f5d4021e91c4a8f3ed1708730f2cedae47b2c1106c13c79a1a4e55000d539b7d2feaf4d0895f875ce1c433897c998a08d82
|
@@ -17,17 +17,22 @@ module Grape
|
|
17
17
|
paths << _build_rest_uri(root, *prepared_value)
|
18
18
|
paths << prepared_value.pop
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
attr = param.singularize.foreign_key
|
23
|
-
requires attr.to_sym, type: Integer, desc: attr.titleize
|
24
|
-
end
|
20
|
+
nested_params = [root, *[prepared_value]].flatten.map do |param|
|
21
|
+
param.singularize.foreign_key
|
25
22
|
end
|
26
23
|
|
27
|
-
paths.each
|
24
|
+
paths.each do |path|
|
25
|
+
resource path do
|
26
|
+
yield nested_params
|
27
|
+
end
|
28
|
+
end
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
32
|
+
def add_required_params(params)
|
33
|
+
Grape::Validations::ParamsScope.new(api: self, type: Hash).add_required_params(params)
|
34
|
+
end
|
35
|
+
|
31
36
|
private
|
32
37
|
|
33
38
|
def _build_rest_uri(*elements)
|