pragmatic_serializer 0.4.1 → 0.4.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: 1305be660f3ab487df094f12a1cfa59c83e5600d
4
- data.tar.gz: 20b92366f827032fc42f874e8d6c79d2e4950159
3
+ metadata.gz: fffb316e41424a70cddb1a292aa40a69f4f72031
4
+ data.tar.gz: 9bf21eeacf02dc899519bca0a1ab35e52882c21a
5
5
  SHA512:
6
- metadata.gz: e2962de69267aa73a2fdb8665e6a3ea7057ebec78f1baab0dffd9ea09ddbcd76a2d902e7136913a4879df055ddc3ddf8f41a9d7bbcf7ab2a0f7a8c4b78289c37
7
- data.tar.gz: b5af38c6be3a88735e39a02b6c38fbc03cc4d77b0226d72f035ea30f184287c0e3f2f913979ec1f13c8ee162a4aef3b273cc9d0f9758651cb84db357a2147298
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 = { collection_prefix => as_unprefixed_json }
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
@@ -1,3 +1,3 @@
1
1
  module PragmaticSerializer
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pragmatic_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Valent