grape_ape_rails 0.9.5 → 0.9.6
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/grape_ape_rails/handlers/formatters.rb +9 -2
- data/lib/grape_ape_rails/version.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- 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: e03d7f7a7e36fd329b6dfcb1867b7aee6ef4568e
|
4
|
+
data.tar.gz: 5a65a3f44ed5e00f819683a7822ac907fe854c49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 673e12e5793ce6a364bd2558959d35ef211c8ab0f5c14f3bc6c62ddbc38c5cf0be87e26e21dc3a66348cf62b5aee2bd44d8d3f9b7e8a589ed03edec502a156db
|
7
|
+
data.tar.gz: 21de466677b803289f15941af1626f0aa4f9e2bc64f8f89b0a1a928a32fe63858b26e45c7af63f3b2e415d62ea5d964745f367d079c79e4b8a67435a9a58b5a0
|
@@ -37,11 +37,18 @@ module Grape
|
|
37
37
|
single = serializer.try(:resource_singular) || serializer.instance_variable_get(:@resource_name).try(:singularize) || serializer.instance_variable_get(:@object).class.name.underscore
|
38
38
|
plural = serializer.try(:resource_plural) || serializer.instance_variable_get(:@resource_name) || single.pluralize
|
39
39
|
|
40
|
-
return %Q[{\"result\":#{MultiJson.dump(serializer)}}] if [serializer.object].flatten.size >
|
40
|
+
return %Q[{\"result\":#{MultiJson.dump(serializer)}}] if [serializer.object].flatten.size > 1
|
41
41
|
|
42
42
|
serializer.root = false
|
43
43
|
out = serializer.object.try(:empty?) ? nil : MultiJson.dump(serializer)
|
44
|
-
|
44
|
+
if out.present? && out[0,1] == '[' && out[-1,1] == ']'
|
45
|
+
# was probably a single mongoid criteria object or some enumerable that serialized itself into a json array
|
46
|
+
out = out
|
47
|
+
else
|
48
|
+
# its a singular record, so we want to put it in an array
|
49
|
+
out = "[#{out}]"
|
50
|
+
end
|
51
|
+
%Q[{\"result\":{\"#{plural}\":#{out}}}]
|
45
52
|
else
|
46
53
|
Grape::Formatter::GarJsonSerializer.call serializer.object, env
|
47
54
|
end
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|