pragmatic_serializer 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/pragmatic_serializer/collection_serializer.rb +11 -2
- data/lib/pragmatic_serializer/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: 926b6c50978c57be6a32964d128a84a595de629a
|
4
|
+
data.tar.gz: 722bf1b2568511270ee64bd1d832fd3a06a633fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdd54bf491c4dfd4e19ba61ac7c01a5407914241aa03d0e1b2ca7d6d51acfa31c6f4721d6c90e675b3e5348a465594cbb5eccfd37eb24097451dfad29cbb5946
|
7
|
+
data.tar.gz: 6ff6fd3792a9794afa25b698af2d22ee17b396a7cdbb9cc581c298ff8b62f24ca4404afc975dd5a5b248cc7e4b62078a530d66931df442f8699839d256787a5f
|
data/README.md
CHANGED
@@ -149,6 +149,7 @@ serializer = CommentSerializer.collection(paginated_comments)
|
|
149
149
|
serializer.limit = limit
|
150
150
|
serializer.offset = offset
|
151
151
|
serializer.total = @comments.size
|
152
|
+
# serializer.resource_serializer_wrapper = ->(x) { begin x; rescue ActiveRecor::Base; end}
|
152
153
|
# serializer.resource_options.include_work = true # to pass more options to individual resource serializer
|
153
154
|
# serializer.include_resources_json = false # to skip rendering resources json array
|
154
155
|
serializer.pagination_evaluator = ->(limit:, offset:) {
|
@@ -21,7 +21,8 @@ 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,
|
25
|
+
:include_resources_json, :resource_serializer_wrapper
|
25
26
|
attr_accessor :resources, :total, :resource_serializer, :pagination_evaluator
|
26
27
|
|
27
28
|
def resource_options
|
@@ -61,7 +62,15 @@ module PragmaticSerializer
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def as_unprefixed_json
|
64
|
-
collection_serializers
|
65
|
+
collection_serializers
|
66
|
+
.map do |rs|
|
67
|
+
resource_serializer_wrapper.call(rs.send(serialization_method))
|
68
|
+
end
|
69
|
+
.compact
|
70
|
+
end
|
71
|
+
|
72
|
+
def resource_serializer_wrapper
|
73
|
+
@resource_serializer_wrapper ||= ->(x) {x}
|
65
74
|
end
|
66
75
|
|
67
76
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pragmatic_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Valent
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|