jsonapi-resources 0.10.6 → 0.10.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '091836afd689ed975ab1ad2cee54a467a0771cb5ea5b0bfa2055e25531809f74'
4
- data.tar.gz: 96d46c67f8c88fa3e6d298eac85dc3862bef6feacbe8eddde1515b80e7c8e5a8
3
+ metadata.gz: d30a2ea26f6bb9f907e0710a7e9d95a9682bfa64ab0fd7ae1e5b350c07f52924
4
+ data.tar.gz: fd883de5a6506f4aaad03fcf3ec61ec311c0e57f0cf33ea8c3d8b082c47b2671
5
5
  SHA512:
6
- metadata.gz: f4dfc6fd61f4a7d27a291626b00c6e5c13cad32be0b73b66e239f254800d73557168470191923cd5bcf29869bfdb1e93a11c4a8b6e3eca25411b1ac8dbc4e24d
7
- data.tar.gz: e6c699748872330b22ae151082595e48bed10665e9c61c3ba902f585747090e19ab9319776d189bc06fe9ca7797f00467fb08a3e863a4ce7e3b740fd85bc2fe8
6
+ metadata.gz: cc53b7071fb93b2f2f5c8ff2f02b43572a56d5da8a58835cff73953100db55c0ea9dbc2a1d26b7b06ae854d8e588276619d7631a4dc509e7c6332b9ced5c6245
7
+ data.tar.gz: d9f77c39f058f3978b20ccba5d2beea4744bbda9cb1b19933ed9a3a235a5265a9fecb945a2fd3646f0135cb97059896be3ac2fa19023a94fd555480ac8483f95
@@ -13,9 +13,16 @@ module JSONAPI
13
13
  # :nocov:
14
14
  end
15
15
 
16
+ def requires_record_count
17
+ # :nocov:
18
+ self.class.requires_record_count
19
+ # :nocov:
20
+ end
21
+
16
22
  class << self
17
23
  def requires_record_count
18
24
  # :nocov:
25
+ # @deprecated
19
26
  false
20
27
  # :nocov:
21
28
  end
@@ -36,10 +43,15 @@ class OffsetPaginator < JSONAPI::Paginator
36
43
  verify_pagination_params
37
44
  end
38
45
 
46
+ # @deprecated
39
47
  def self.requires_record_count
40
48
  true
41
49
  end
42
50
 
51
+ def requires_record_count
52
+ true
53
+ end
54
+
43
55
  def apply(relation, _order_options)
44
56
  relation.offset(@offset).limit(@limit)
45
57
  end
@@ -127,10 +139,15 @@ class PagedPaginator < JSONAPI::Paginator
127
139
  verify_pagination_params
128
140
  end
129
141
 
142
+ # @deprecated
130
143
  def self.requires_record_count
131
144
  true
132
145
  end
133
146
 
147
+ def requires_record_count
148
+ true
149
+ end
150
+
134
151
  def calculate_page_count(record_count)
135
152
  (record_count / @size.to_f).ceil
136
153
  end
@@ -65,13 +65,13 @@ module JSONAPI
65
65
  resource_set.populate!(serializer, context, find_options)
66
66
 
67
67
  page_options = result_options
68
- if (JSONAPI.configuration.top_level_meta_include_record_count || (paginator && paginator.class.requires_record_count))
68
+ if (top_level_meta_include_record_count || (paginator && paginator.requires_record_count))
69
69
  page_options[:record_count] = resource_klass.count(verified_filters,
70
70
  context: context,
71
71
  include_directives: include_directives)
72
72
  end
73
73
 
74
- if (JSONAPI.configuration.top_level_meta_include_page_count && paginator && page_options[:record_count])
74
+ if (top_level_meta_include_page_count && paginator && page_options[:record_count])
75
75
  page_options[:page_count] = paginator ? paginator.calculate_page_count(page_options[:record_count]) : 1
76
76
  end
77
77
 
@@ -197,9 +197,9 @@ module JSONAPI
197
197
  resource_set.populate!(serializer, context, find_options)
198
198
 
199
199
  opts = result_options
200
- if ((JSONAPI.configuration.top_level_meta_include_record_count) ||
201
- (paginator && paginator.class.requires_record_count) ||
202
- (JSONAPI.configuration.top_level_meta_include_page_count))
200
+ if ((top_level_meta_include_record_count) ||
201
+ (paginator && paginator.requires_record_count) ||
202
+ (top_level_meta_include_page_count))
203
203
 
204
204
  opts[:record_count] = source_resource.class.count_related(
205
205
  source_resource.identity,
@@ -207,13 +207,13 @@ module JSONAPI
207
207
  find_options)
208
208
  end
209
209
 
210
- if (JSONAPI.configuration.top_level_meta_include_page_count && opts[:record_count])
210
+ if (top_level_meta_include_page_count && opts[:record_count])
211
211
  opts[:page_count] = paginator.calculate_page_count(opts[:record_count])
212
212
  end
213
213
 
214
214
  opts[:pagination_params] = if paginator && JSONAPI.configuration.top_level_links_include_pagination
215
215
  page_options = {}
216
- page_options[:record_count] = opts[:record_count] if paginator.class.requires_record_count
216
+ page_options[:record_count] = opts[:record_count] if paginator.requires_record_count
217
217
  paginator.links_page_params(page_options.merge(fetched_resources: resource_set))
218
218
  else
219
219
  {}
@@ -382,6 +382,14 @@ module JSONAPI
382
382
  JSONAPI::ResourceSet.new(resource_id_tree)
383
383
  end
384
384
 
385
+ def top_level_meta_include_record_count
386
+ JSONAPI.configuration.top_level_meta_include_record_count
387
+ end
388
+
389
+ def top_level_meta_include_page_count
390
+ JSONAPI.configuration.top_level_meta_include_page_count
391
+ end
392
+
385
393
  private
386
394
  def find_related_resource_id_tree(resource_klass, source_id, relationship_name, find_options, include_related)
387
395
  options = find_options.except(:include_directives)
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Resources
3
- VERSION = '0.10.6'
3
+ VERSION = '0.10.7'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.6
4
+ version: 0.10.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Gebhardt
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-02-07 00:00:00.000000000 Z
12
+ date: 2022-03-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler