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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fffb316e41424a70cddb1a292aa40a69f4f72031
4
- data.tar.gz: 9bf21eeacf02dc899519bca0a1ab35e52882c21a
3
+ metadata.gz: 926b6c50978c57be6a32964d128a84a595de629a
4
+ data.tar.gz: 722bf1b2568511270ee64bd1d832fd3a06a633fa
5
5
  SHA512:
6
- metadata.gz: 59cb609a859605f06a0cff4da91429804cb99de2b8550519c69eb5d736b4830aa5a04310559b7e90322698d6d89cd43d8b068f3b6787ce9cf24592e303b2e470
7
- data.tar.gz: 9c6cb0cf84c3b48d637d78ed5813367d7a110d69ce8f829faa51554b10f6596a29acd7af730de11a0dbf57a794faa0474add50330c195bbe8e50769c5ecc2435
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, :include_resources_json
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.map { |rs| rs.send(serialization_method) }
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
@@ -1,3 +1,3 @@
1
1
  module PragmaticSerializer
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
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.2
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-12 00:00:00.000000000 Z
11
+ date: 2018-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport