pragmatic_serializer 0.4.1 → 0.4.2
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/README.md +2 -1
- data/lib/pragmatic_serializer/collection_serializer.rb +8 -2
- data/lib/pragmatic_serializer/version.rb +1 -1
- 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: fffb316e41424a70cddb1a292aa40a69f4f72031
|
4
|
+
data.tar.gz: 9bf21eeacf02dc899519bca0a1ab35e52882c21a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59cb609a859605f06a0cff4da91429804cb99de2b8550519c69eb5d736b4830aa5a04310559b7e90322698d6d89cd43d8b068f3b6787ce9cf24592e303b2e470
|
7
|
+
data.tar.gz: 9c6cb0cf84c3b48d637d78ed5813367d7a110d69ce8f829faa51554b10f6596a29acd7af730de11a0dbf57a794faa0474add50330c195bbe8e50769c5ecc2435
|
data/README.md
CHANGED
@@ -149,7 +149,8 @@ serializer = CommentSerializer.collection(paginated_comments)
|
|
149
149
|
serializer.limit = limit
|
150
150
|
serializer.offset = offset
|
151
151
|
serializer.total = @comments.size
|
152
|
-
# serializer.resource_options.include_work = true
|
152
|
+
# serializer.resource_options.include_work = true # to pass more options to individual resource serializer
|
153
|
+
# serializer.include_resources_json = false # to skip rendering resources json array
|
153
154
|
serializer.pagination_evaluator = ->(limit:, offset:) {
|
154
155
|
comments_path(limit: limit, offset: offset)
|
155
156
|
}
|
@@ -21,7 +21,7 @@ module PragmaticSerializer
|
|
21
21
|
extend Forwardable
|
22
22
|
include PragmaticSerializer::ConfigInterface
|
23
23
|
|
24
|
-
attr_writer :limit, :offset, :serialization_method
|
24
|
+
attr_writer :limit, :offset, :serialization_method, :include_resources_json
|
25
25
|
attr_accessor :resources, :total, :resource_serializer, :pagination_evaluator
|
26
26
|
|
27
27
|
def resource_options
|
@@ -48,8 +48,14 @@ module PragmaticSerializer
|
|
48
48
|
@offset ||= config.default_offset
|
49
49
|
end
|
50
50
|
|
51
|
+
def include_resources_json
|
52
|
+
return @include_resources_json unless @include_resources_json.nil?
|
53
|
+
@include_resources_json ||= true
|
54
|
+
end
|
55
|
+
|
51
56
|
def as_json
|
52
|
-
hash = {
|
57
|
+
hash = {}
|
58
|
+
hash.merge!({ collection_prefix => as_unprefixed_json }) if include_resources_json
|
53
59
|
hash.merge!(pagination_json.as_json) if pagination_evaluator
|
54
60
|
hash
|
55
61
|
end
|