grape_json_api_streamer 0.0.5 → 0.0.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/json_api/streamer.rb +8 -3
- data/lib/grape/json_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e80c58c6897119112612ba37161cda6445fa0b4a
|
4
|
+
data.tar.gz: ee78ff0cef3bba5beeed0d5dac233a2e77617886
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12cfdc2b71d666d9fceb7e7f7f7efff4e693142b9533b4431e07585bc540e2e124d9ae701f09e32f1014aa986a51afa3b94596fb27654e235e8f402f67aa8a96
|
7
|
+
data.tar.gz: aa21cbbfe37d8cf97d1a6c8b917fe51418fba22cdbc39d81d643b9250806539e41f15c8e8fa3d6cd7ead7f93e6d358386d64ef0024ecd078f5227cbd097a1b90
|
@@ -6,11 +6,13 @@ module Grape
|
|
6
6
|
def initialize(collection, options = {})
|
7
7
|
@collection = collection
|
8
8
|
@options = ActiveSupport::HashWithIndifferentAccess.new(options)
|
9
|
+
@meta = @options[:meta]
|
10
|
+
@links = @options[:links]
|
9
11
|
end
|
10
12
|
|
11
13
|
def each
|
12
14
|
yield '{'
|
13
|
-
yield "\"meta\": #{JSON.unparse(@
|
15
|
+
yield "\"meta\": #{JSON.unparse(@meta)}," if @meta
|
14
16
|
yield '"data":['
|
15
17
|
first = true
|
16
18
|
@collection.lazy.each do |object|
|
@@ -22,12 +24,15 @@ module Grape
|
|
22
24
|
yield buffer
|
23
25
|
end
|
24
26
|
yield ']'
|
25
|
-
yield ",\"links\": #{JSON.unparse(@
|
27
|
+
yield ",\"links\": #{JSON.unparse(@links)}" if @links
|
26
28
|
yield '}'
|
27
29
|
end
|
28
30
|
|
29
31
|
def serialize(model)
|
30
|
-
|
32
|
+
@options.delete(:meta)
|
33
|
+
@options.delete(:links)
|
34
|
+
@options[:is_collection] = false
|
35
|
+
::JSONAPI::Serializer.serialize(model, @options)
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape_json_api_streamer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Roy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape
|