grape_ape_rails 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 538ba6a4cbe421342e7575867c44c41da0d780cd
4
- data.tar.gz: 77c5426d1d7966022d346563578eb1966c24fb91
3
+ metadata.gz: e03d7f7a7e36fd329b6dfcb1867b7aee6ef4568e
4
+ data.tar.gz: 5a65a3f44ed5e00f819683a7822ac907fe854c49
5
5
  SHA512:
6
- metadata.gz: fdfe5587170319a5b2ee41538b3b4ae1633499e0329e8cbf890d2cc8419c1c142d3fbbda84169e458f5c84d13f154deb051986ea5379987b3ca1e9b5147f3a60
7
- data.tar.gz: 49668f635f052ffd13cfe046e7c0b220202b170e9f02f5f4791ff33f774e3f30c9693754b0fdc344c413de63c68b376a1734e89a42f83cde9ee39e02c15a0aac
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 > 0
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
- %Q[{\"result\":{\"#{plural}\":[#{out}]}}]
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
@@ -1,3 +1,3 @@
1
1
  module GrapeApeRails
2
- VERSION = "0.9.5"
2
+ VERSION = "0.9.6"
3
3
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape_ape_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt E. Patterson