grape-jsonapi-resources 0.0.1 → 0.0.2

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: 66ed30fd8d9408e26b35c52db9035123f83efa94
4
- data.tar.gz: fe03036472c71e70ab7b287dc5696a29f71d7ef1
3
+ metadata.gz: 1482149e25e0b798ea671dd78d8ad46ecdbf45ab
4
+ data.tar.gz: fefd078234f23d2fd4a1ed432e8f9cd03f223753
5
5
  SHA512:
6
- metadata.gz: eec5d985fa7a1d518f24ec3f5646f44cb891fbcb7a531d7d3035fc861bfe6de422f005540e0a46ef27ecdc9a7762d37360098b1a7cb419866c16576ff9d3ea29
7
- data.tar.gz: 4d0a59553e96d9e29333aa4be6a50cdfb6d5f48e371bbfba71e4b1bc2643ec6b1767edcee91142e602f86052a93ec2214d26785bd0643243146798463bc84739
6
+ metadata.gz: f19321fbb60946b17527c5aae964fec9f2e9ec4b7678ae6102e37532a02a35d213b083ee9826b200410728dfde178cb4cd0c3deb92ca9bc8822924877191a8d7
7
+ data.tar.gz: 093c57eb13304e1268ea845d7d73db392bbb47a9620ddd9aec2c4a780d215bc602c3f6018fd49f2b3960b2d3af9606d673d1ab16f73498f9fc3f64349b6a97ae
@@ -17,7 +17,19 @@ module Grape
17
17
  context.merge!(jsonapi_options.delete(:context)) if jsonapi_options[:context]
18
18
 
19
19
  resource_class = resource_class_for(resource)
20
- return nil unless resource_class
20
+
21
+ unless resource_class
22
+ # Return blank object
23
+ blank_return = {}
24
+ if resource.is_a?(Array)
25
+ blank_return[:data] = []
26
+ else
27
+ blank_return[:data] = {}
28
+ end
29
+ blank_return[:meta] = jsonapi_options[:meta] if jsonapi_options[:meta]
30
+ return blank_return.to_json
31
+ end
32
+
21
33
  resource_instances = nil
22
34
  if resource.respond_to?(:to_ary)
23
35
  resource_instances = resource.to_ary.collect do |each_resource|
@@ -1,5 +1,5 @@
1
1
  module Grape
2
2
  module JSONAPIResources
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-jsonapi-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cary Dunn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-30 00:00:00.000000000 Z
11
+ date: 2015-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  requirements: []
147
147
  rubyforge_project:
148
- rubygems_version: 2.4.5
148
+ rubygems_version: 2.4.5.1
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: Use jsonapi-resources in grape