active_model_serializers 0.10.12 → 0.10.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +0 -1
- data/lib/active_model/serializer/collection_serializer.rb +11 -2
- data/lib/active_model/serializer/version.rb +1 -1
- data/lib/active_model/serializer.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/pagination_links.rb +5 -1
- data/lib/active_model_serializers/model/caching.rb +1 -0
- metadata +10 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94ecdeeabcad7f33e6b2891f2354edeb1fdabf444d9938014d839b554f0a5ab7
|
4
|
+
data.tar.gz: cd43b9ceddf4920feb4efae6c5d0748bbb6e37111328c015cdcca06ba8f9d86d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93b28755ff8f015277534dfc971cab0ef5bf30745bebb34c90e2f6e17c1cb611ef1100ba9e484ebdd1dc415d2c9d1c7e715984a1052e75daada8f712b1126850
|
7
|
+
data.tar.gz: 86d257304d0e58b87e82a8c32f55a7722ffdc568dd394ac93214dfe382bf8ff27c8bed24c11f6a948184a16a67ad5fa7bbaf98f2443b2d11c017ce5463c58947
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
## 0.10.x
|
2
2
|
|
3
|
-
### [master (unreleased)](https://github.com/rails-api/active_model_serializers/compare/v0.10.
|
3
|
+
### [master (unreleased)](https://github.com/rails-api/active_model_serializers/compare/v0.10.13...0-10-stable)
|
4
4
|
|
5
5
|
Breaking changes:
|
6
6
|
|
@@ -10,6 +10,12 @@ Fixes:
|
|
10
10
|
|
11
11
|
Misc:
|
12
12
|
|
13
|
+
### [v0.10.13 (2022-01013)](https://github.com/rails-api/active_model_serializers/compare/v0.10.12...v0.10.13)
|
14
|
+
|
15
|
+
Fixes:
|
16
|
+
|
17
|
+
- [#2399](https://github.com/rails-api/active_model_serializers/pull/2399) Handles edge case where requested current_page > total_pages (@f3z0)
|
18
|
+
|
13
19
|
### [v0.10.12 (2020-12-10)](https://github.com/rails-api/active_model_serializers/compare/v0.10.11...v0.10.12)
|
14
20
|
|
15
21
|
Fixes:
|
data/README.md
CHANGED
@@ -13,7 +13,6 @@
|
|
13
13
|
<td>
|
14
14
|
<a href="https://codeclimate.com/github/rails-api/active_model_serializers"><img src="https://codeclimate.com/github/rails-api/active_model_serializers/badges/gpa.svg" alt="Code Quality"></a>
|
15
15
|
<a href="https://codebeat.co/projects/github-com-rails-api-active_model_serializers"><img src="https://codebeat.co/badges/a9ab35fa-8b5a-4680-9d4e-a81f9a55ebcd" alt="codebeat" ></a>
|
16
|
-
<a href="https://codeclimate.com/github/rails-api/active_model_serializers/coverage"><img src="https://codeclimate.com/github/rails-api/active_model_serializers/badges/coverage.svg" alt="Test Coverage"></a>
|
17
16
|
</td>
|
18
17
|
</tr>
|
19
18
|
<tr>
|
@@ -48,8 +48,11 @@ module ActiveModel
|
|
48
48
|
key ||= object.respond_to?(:name) ? object.name && object.name.underscore : nil
|
49
49
|
# 4. key may be nil for empty collection and no serializer option
|
50
50
|
key &&= key.pluralize
|
51
|
-
|
52
|
-
|
51
|
+
if raise_cannot_infer_root_key_error?
|
52
|
+
# 5. fail if the key cannot be determined
|
53
|
+
key || fail(CannotInferRootKeyError, 'Cannot infer root key from collection type. Please specify the root or each_serializer option, or render a JSON String')
|
54
|
+
end
|
55
|
+
key
|
53
56
|
end
|
54
57
|
# rubocop:enable Metrics/CyclomaticComplexity
|
55
58
|
|
@@ -60,12 +63,18 @@ module ActiveModel
|
|
60
63
|
object.respond_to?(:size)
|
61
64
|
end
|
62
65
|
|
66
|
+
class CannotInferRootKeyError < StandardError; end
|
67
|
+
|
63
68
|
protected
|
64
69
|
|
65
70
|
attr_reader :serializers, :options
|
66
71
|
|
67
72
|
private
|
68
73
|
|
74
|
+
def raise_cannot_infer_root_key_error?
|
75
|
+
ActiveModelSerializers.config.raise_cannot_infer_root_key_error
|
76
|
+
end
|
77
|
+
|
69
78
|
def serializers_from_resources
|
70
79
|
serializer_context_class = options.fetch(:serializer_context_class, ActiveModel::Serializer)
|
71
80
|
object.map do |resource|
|
@@ -146,6 +146,8 @@ module ActiveModel
|
|
146
146
|
config.jsonapi_include_toplevel_object = false
|
147
147
|
config.jsonapi_use_foreign_key_on_belongs_to_relationship = false
|
148
148
|
config.include_data_default = true
|
149
|
+
# Raise ActiveModel::Serializer::CollectionSerializer::CannotInferRootKeyError when cannot infer root key from collection type
|
150
|
+
config.raise_cannot_infer_root_key_error = true
|
149
151
|
|
150
152
|
# For configuring how serializers are found.
|
151
153
|
# This should be an array of procs.
|
@@ -55,11 +55,15 @@ module ActiveModelSerializers
|
|
55
55
|
|
56
56
|
def prev_page_url
|
57
57
|
return nil if collection.current_page == FIRST_PAGE
|
58
|
+
if collection.current_page > collection.total_pages
|
59
|
+
return url_for_page(collection.total_pages)
|
60
|
+
end
|
58
61
|
url_for_page(collection.current_page - FIRST_PAGE)
|
59
62
|
end
|
60
63
|
|
61
64
|
def next_page_url
|
62
|
-
return nil if collection.total_pages == 0 ||
|
65
|
+
return nil if collection.total_pages == 0 ||
|
66
|
+
collection.current_page >= collection.total_pages
|
63
67
|
url_for_page(collection.next_page)
|
64
68
|
end
|
65
69
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_model_serializers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Klabnik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '4.1'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '7.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '4.1'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '7.1'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: actionpack
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: '4.1'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '7.1'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: '4.1'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '7.1'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: railties
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
version: '4.1'
|
60
60
|
- - "<"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
62
|
+
version: '7.1'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -69,7 +69,7 @@ dependencies:
|
|
69
69
|
version: '4.1'
|
70
70
|
- - "<"
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: '
|
72
|
+
version: '7.1'
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: minitest
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,7 +133,7 @@ dependencies:
|
|
133
133
|
version: '4.1'
|
134
134
|
- - "<"
|
135
135
|
- !ruby/object:Gem::Version
|
136
|
-
version: '
|
136
|
+
version: '7.1'
|
137
137
|
type: :development
|
138
138
|
prerelease: false
|
139
139
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -143,7 +143,7 @@ dependencies:
|
|
143
143
|
version: '4.1'
|
144
144
|
- - "<"
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version: '
|
146
|
+
version: '7.1'
|
147
147
|
- !ruby/object:Gem::Dependency
|
148
148
|
name: kaminari
|
149
149
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,20 +192,6 @@ dependencies:
|
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
|
-
- !ruby/object:Gem::Dependency
|
196
|
-
name: simplecov
|
197
|
-
requirement: !ruby/object:Gem::Requirement
|
198
|
-
requirements:
|
199
|
-
- - ">="
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: '0.11'
|
202
|
-
type: :development
|
203
|
-
prerelease: false
|
204
|
-
version_requirements: !ruby/object:Gem::Requirement
|
205
|
-
requirements:
|
206
|
-
- - ">="
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: '0.11'
|
209
195
|
- !ruby/object:Gem::Dependency
|
210
196
|
name: timecop
|
211
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -227,9 +213,6 @@ dependencies:
|
|
227
213
|
- - ">="
|
228
214
|
- !ruby/object:Gem::Version
|
229
215
|
version: '0.13'
|
230
|
-
- - "<"
|
231
|
-
- !ruby/object:Gem::Version
|
232
|
-
version: 0.19.1
|
233
216
|
type: :development
|
234
217
|
prerelease: false
|
235
218
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -237,9 +220,6 @@ dependencies:
|
|
237
220
|
- - ">="
|
238
221
|
- !ruby/object:Gem::Version
|
239
222
|
version: '0.13'
|
240
|
-
- - "<"
|
241
|
-
- !ruby/object:Gem::Version
|
242
|
-
version: 0.19.1
|
243
223
|
- !ruby/object:Gem::Dependency
|
244
224
|
name: json_schema
|
245
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -261,9 +241,6 @@ dependencies:
|
|
261
241
|
- - ">="
|
262
242
|
- !ruby/object:Gem::Version
|
263
243
|
version: '10.0'
|
264
|
-
- - "<"
|
265
|
-
- !ruby/object:Gem::Version
|
266
|
-
version: '13.0'
|
267
244
|
type: :development
|
268
245
|
prerelease: false
|
269
246
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -271,9 +248,6 @@ dependencies:
|
|
271
248
|
- - ">="
|
272
249
|
- !ruby/object:Gem::Version
|
273
250
|
version: '10.0'
|
274
|
-
- - "<"
|
275
|
-
- !ruby/object:Gem::Version
|
276
|
-
version: '13.0'
|
277
251
|
description: ActiveModel::Serializers allows you to generate your JSON in an object-oriented
|
278
252
|
and convention-driven manner.
|
279
253
|
email:
|