active_model_serializers 0.10.8 → 0.10.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/.travis.yml +12 -3
- data/CHANGELOG.md +14 -1
- data/Gemfile +3 -1
- data/Rakefile +2 -0
- data/active_model_serializers.gemspec +1 -0
- data/lib/action_controller/serialization.rb +2 -0
- data/lib/active_model/serializable_resource.rb +2 -0
- data/lib/active_model/serializer.rb +2 -0
- data/lib/active_model/serializer/adapter.rb +2 -0
- data/lib/active_model/serializer/adapter/attributes.rb +2 -0
- data/lib/active_model/serializer/adapter/base.rb +2 -0
- data/lib/active_model/serializer/adapter/json.rb +2 -0
- data/lib/active_model/serializer/adapter/json_api.rb +2 -0
- data/lib/active_model/serializer/adapter/null.rb +2 -0
- data/lib/active_model/serializer/array_serializer.rb +2 -0
- data/lib/active_model/serializer/association.rb +2 -0
- data/lib/active_model/serializer/attribute.rb +2 -0
- data/lib/active_model/serializer/belongs_to_reflection.rb +2 -0
- data/lib/active_model/serializer/collection_serializer.rb +2 -0
- data/lib/active_model/serializer/concerns/caching.rb +5 -1
- data/lib/active_model/serializer/error_serializer.rb +2 -0
- data/lib/active_model/serializer/errors_serializer.rb +2 -0
- data/lib/active_model/serializer/field.rb +2 -0
- data/lib/active_model/serializer/fieldset.rb +2 -0
- data/lib/active_model/serializer/has_many_reflection.rb +2 -0
- data/lib/active_model/serializer/has_one_reflection.rb +2 -0
- data/lib/active_model/serializer/lazy_association.rb +5 -2
- data/lib/active_model/serializer/link.rb +2 -0
- data/lib/active_model/serializer/lint.rb +2 -0
- data/lib/active_model/serializer/null.rb +2 -0
- data/lib/active_model/serializer/reflection.rb +2 -0
- data/lib/active_model/serializer/version.rb +3 -1
- data/lib/active_model_serializers.rb +2 -0
- data/lib/active_model_serializers/adapter.rb +3 -1
- data/lib/active_model_serializers/adapter/attributes.rb +2 -0
- data/lib/active_model_serializers/adapter/base.rb +2 -0
- data/lib/active_model_serializers/adapter/json.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/deserialization.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/error.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/jsonapi.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/link.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/meta.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/pagination_links.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/relationship.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/resource_identifier.rb +2 -0
- data/lib/active_model_serializers/adapter/null.rb +2 -0
- data/lib/active_model_serializers/callbacks.rb +2 -0
- data/lib/active_model_serializers/deprecate.rb +2 -0
- data/lib/active_model_serializers/deserialization.rb +2 -0
- data/lib/active_model_serializers/json_pointer.rb +2 -0
- data/lib/active_model_serializers/logging.rb +2 -0
- data/lib/active_model_serializers/lookup_chain.rb +2 -0
- data/lib/active_model_serializers/model.rb +2 -0
- data/lib/active_model_serializers/railtie.rb +2 -0
- data/lib/active_model_serializers/register_jsonapi_renderer.rb +2 -0
- data/lib/active_model_serializers/serializable_resource.rb +4 -2
- data/lib/active_model_serializers/serialization_context.rb +2 -0
- data/lib/active_model_serializers/test.rb +2 -0
- data/lib/active_model_serializers/test/schema.rb +2 -0
- data/lib/active_model_serializers/test/serializer.rb +2 -0
- data/lib/generators/rails/resource_override.rb +2 -0
- data/lib/generators/rails/serializer_generator.rb +2 -0
- data/lib/grape/active_model_serializers.rb +2 -0
- data/lib/grape/formatters/active_model_serializers.rb +2 -0
- data/lib/grape/helpers/active_model_serializers.rb +2 -0
- data/lib/tasks/rubocop.rake +2 -0
- data/test/action_controller/adapter_selector_test.rb +2 -0
- data/test/action_controller/explicit_serializer_test.rb +2 -0
- data/test/action_controller/json/include_test.rb +2 -0
- data/test/action_controller/json_api/deserialization_test.rb +2 -0
- data/test/action_controller/json_api/errors_test.rb +2 -0
- data/test/action_controller/json_api/fields_test.rb +2 -0
- data/test/action_controller/json_api/linked_test.rb +2 -0
- data/test/action_controller/json_api/pagination_test.rb +2 -0
- data/test/action_controller/json_api/transform_test.rb +2 -0
- data/test/action_controller/lookup_proc_test.rb +2 -0
- data/test/action_controller/namespace_lookup_test.rb +2 -0
- data/test/action_controller/serialization_scope_name_test.rb +2 -0
- data/test/action_controller/serialization_test.rb +2 -0
- data/test/active_model_serializers/adapter_for_test.rb +2 -0
- data/test/active_model_serializers/json_pointer_test.rb +2 -0
- data/test/active_model_serializers/logging_test.rb +2 -0
- data/test/active_model_serializers/model_test.rb +2 -0
- data/test/active_model_serializers/railtie_test_isolated.rb +2 -0
- data/test/active_model_serializers/register_jsonapi_renderer_test_isolated.rb +2 -0
- data/test/active_model_serializers/serialization_context_test_isolated.rb +2 -0
- data/test/active_model_serializers/test/schema_test.rb +2 -0
- data/test/active_model_serializers/test/serializer_test.rb +2 -0
- data/test/active_record_test.rb +2 -0
- data/test/adapter/attributes_test.rb +2 -0
- data/test/adapter/deprecation_test.rb +2 -0
- data/test/adapter/json/belongs_to_test.rb +2 -0
- data/test/adapter/json/collection_test.rb +2 -0
- data/test/adapter/json/has_many_test.rb +2 -0
- data/test/adapter/json/transform_test.rb +2 -0
- data/test/adapter/json_api/belongs_to_test.rb +2 -0
- data/test/adapter/json_api/collection_test.rb +2 -0
- data/test/adapter/json_api/errors_test.rb +2 -0
- data/test/adapter/json_api/fields_test.rb +2 -0
- data/test/adapter/json_api/has_many_explicit_serializer_test.rb +2 -0
- data/test/adapter/json_api/has_many_test.rb +2 -0
- data/test/adapter/json_api/has_one_test.rb +2 -0
- data/test/adapter/json_api/include_data_if_sideloaded_test.rb +2 -0
- data/test/adapter/json_api/json_api_test.rb +2 -0
- data/test/adapter/json_api/linked_test.rb +2 -0
- data/test/adapter/json_api/links_test.rb +2 -0
- data/test/adapter/json_api/pagination_links_test.rb +2 -0
- data/test/adapter/json_api/parse_test.rb +2 -0
- data/test/adapter/json_api/relationship_test.rb +2 -0
- data/test/adapter/json_api/resource_meta_test.rb +2 -0
- data/test/adapter/json_api/toplevel_jsonapi_test.rb +2 -0
- data/test/adapter/json_api/transform_test.rb +2 -0
- data/test/adapter/json_api/type_test.rb +2 -0
- data/test/adapter/json_test.rb +2 -0
- data/test/adapter/null_test.rb +2 -0
- data/test/adapter/polymorphic_test.rb +2 -0
- data/test/adapter_test.rb +2 -0
- data/test/array_serializer_test.rb +2 -0
- data/test/benchmark/app.rb +2 -0
- data/test/benchmark/benchmarking_support.rb +2 -0
- data/test/benchmark/bm_active_record.rb +2 -0
- data/test/benchmark/bm_adapter.rb +2 -0
- data/test/benchmark/bm_caching.rb +2 -0
- data/test/benchmark/bm_lookup_chain.rb +2 -0
- data/test/benchmark/bm_transform.rb +2 -0
- data/test/benchmark/controllers.rb +2 -0
- data/test/benchmark/fixtures.rb +2 -0
- data/test/cache_test.rb +66 -0
- data/test/collection_serializer_test.rb +2 -0
- data/test/fixtures/active_record.rb +2 -0
- data/test/fixtures/poro.rb +2 -0
- data/test/generators/scaffold_controller_generator_test.rb +2 -0
- data/test/generators/serializer_generator_test.rb +2 -0
- data/test/grape_test.rb +2 -0
- data/test/lint_test.rb +2 -0
- data/test/logger_test.rb +2 -0
- data/test/poro_test.rb +2 -0
- data/test/serializable_resource_test.rb +2 -0
- data/test/serializers/association_macros_test.rb +2 -0
- data/test/serializers/associations_test.rb +2 -0
- data/test/serializers/attribute_test.rb +2 -0
- data/test/serializers/attributes_test.rb +2 -0
- data/test/serializers/caching_configuration_test_isolated.rb +2 -0
- data/test/serializers/configuration_test.rb +2 -0
- data/test/serializers/fieldset_test.rb +2 -0
- data/test/serializers/meta_test.rb +2 -0
- data/test/serializers/options_test.rb +2 -0
- data/test/serializers/read_attribute_for_serialization_test.rb +2 -0
- data/test/serializers/reflection_test.rb +2 -0
- data/test/serializers/root_test.rb +2 -0
- data/test/serializers/serialization_test.rb +2 -0
- data/test/serializers/serializer_for_test.rb +2 -0
- data/test/serializers/serializer_for_with_namespace_test.rb +2 -0
- data/test/support/isolated_unit.rb +2 -0
- data/test/support/rails5_shims.rb +2 -0
- data/test/support/rails_app.rb +2 -0
- data/test/support/serialization_testing.rb +2 -0
- data/test/test_helper.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e365d9b8e66fd40b66555a2e57faad48fee5bfd82b988ab42aacda73930bb53c
|
4
|
+
data.tar.gz: bbad118b340ea31c7a09f1f0661d0e53866135a99923276182dc159d4eeb2f9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 011fcf63a00a7cfc27a54679551cf6c03b3dd4ff177192fca7d2be34bfbb2c3b6c6ba40bc92395997a392ed9bf1d91823da15afa7bde374d08f5e9d69982d054
|
7
|
+
data.tar.gz: 8311b1ed270c60ae5d00beaa2e421a350201bec131a44096190f40dfb61a84f11d50ace18c357cc77e364863bef94eebaad717dc78a156c923049679c5295d1d
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -6,9 +6,9 @@ cache:
|
|
6
6
|
- vendor/bundle
|
7
7
|
|
8
8
|
before_install:
|
9
|
-
- "travis_retry gem update --system"
|
10
|
-
- "travis_retry gem
|
11
|
-
install: bundle install --path=vendor/bundle --retry=3 --jobs=3
|
9
|
+
- "travis_retry gem update --system 2.7.8"
|
10
|
+
- "travis_retry gem install bundler -v '1.17.3'"
|
11
|
+
install: BUNDLER_VERSION=1.17.3 bundle install --path=vendor/bundle --retry=3 --jobs=3
|
12
12
|
|
13
13
|
script:
|
14
14
|
- bundle exec rake ci
|
@@ -21,6 +21,7 @@ env:
|
|
21
21
|
- "RAILS_VERSION=4.2"
|
22
22
|
- "RAILS_VERSION=5.0"
|
23
23
|
- "RAILS_VERSION=5.1"
|
24
|
+
- "RAILS_VERSION=5.2"
|
24
25
|
- "RAILS_VERSION=master"
|
25
26
|
|
26
27
|
rvm:
|
@@ -28,8 +29,13 @@ rvm:
|
|
28
29
|
- 2.2.8
|
29
30
|
- 2.3.5
|
30
31
|
- 2.4.2
|
32
|
+
- 2.5.3
|
31
33
|
- ruby-head
|
32
34
|
|
35
|
+
branches:
|
36
|
+
only:
|
37
|
+
- 0-10-stable
|
38
|
+
|
33
39
|
matrix:
|
34
40
|
include:
|
35
41
|
- { rvm: jruby-9.1.13.0, jdk: oraclejdk8, env: "RAILS_VERSION=4.1 JRUBY_OPTS='--dev -J-Xmx1024M --debug'" }
|
@@ -42,9 +48,12 @@ matrix:
|
|
42
48
|
- { rvm: 2.1.10, env: RAILS_VERSION=master }
|
43
49
|
- { rvm: 2.2.8, env: RAILS_VERSION=master }
|
44
50
|
- { rvm: 2.3.5, env: RAILS_VERSION=master }
|
51
|
+
- { rvm: 2.4.2, env: RAILS_VERSION=master }
|
45
52
|
- { rvm: 2.1.10, env: RAILS_VERSION=5.0 }
|
46
53
|
- { rvm: 2.1.10, env: RAILS_VERSION=5.1 }
|
54
|
+
- { rvm: 2.1.10, env: RAILS_VERSION=5.2 }
|
47
55
|
- { rvm: 2.4.2, env: RAILS_VERSION=4.1 }
|
56
|
+
- { rvm: 2.5.3, env: RAILS_VERSION=4.1 }
|
48
57
|
- { rvm: ruby-head, env: RAILS_VERSION=4.1 }
|
49
58
|
allow_failures:
|
50
59
|
- rvm: ruby-head
|
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.9...0-10-stable)
|
4
4
|
|
5
5
|
Breaking changes:
|
6
6
|
|
@@ -8,9 +8,22 @@ Features:
|
|
8
8
|
|
9
9
|
Fixes:
|
10
10
|
|
11
|
+
Misc:
|
12
|
+
|
13
|
+
### [v0.10.9 (2019-02-08)](https://github.com/rails-api/active_model_serializers/compare/v0.10.8...v0.10.9)
|
14
|
+
|
15
|
+
|
16
|
+
Fixes:
|
17
|
+
|
18
|
+
- [#2288](https://github.com/rails-api/active_model_serializers/pull/2288)
|
19
|
+
Change the fetch method to deal with recyclable key cache strategy.
|
20
|
+
Fixes #2287. (@cintamani, @wasifhossain)
|
21
|
+
- [#2307](https://github.com/rails-api/active_model_serializers/pull/2307) Falsey attribute values should not be reevaluated.
|
11
22
|
|
12
23
|
Misc:
|
13
24
|
|
25
|
+
- [#2309](https://github.com/rails-api/active_model_serializers/pull/2309) Performance and memory usage fixes
|
26
|
+
|
14
27
|
### [v0.10.8 (2018-11-01)](https://github.com/rails-api/active_model_serializers/compare/v0.10.7...v0.10.8)
|
15
28
|
|
16
29
|
Features:
|
data/Gemfile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
#
|
3
5
|
# Add a Gemfile.local to locally bundle gems outside of version control
|
@@ -51,7 +53,7 @@ group :bench do
|
|
51
53
|
end
|
52
54
|
|
53
55
|
group :test do
|
54
|
-
gem 'sqlite3', platform: (@windows_platforms + [:ruby])
|
56
|
+
gem 'sqlite3', '~> 1.3.13', platform: (@windows_platforms + [:ruby])
|
55
57
|
platforms :jruby do
|
56
58
|
if version == 'master' || version >= '5'
|
57
59
|
gem 'activerecord-jdbcsqlite3-adapter', '~> 50'
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveModel
|
2
4
|
class Serializer
|
3
5
|
UndefinedCacheKey = Class.new(StandardError)
|
@@ -281,7 +283,9 @@ module ActiveModel
|
|
281
283
|
# Use object's cache_key if available, else derive a key from the object
|
282
284
|
# Pass the `key` option to the `cache` declaration or override this method to customize the cache key
|
283
285
|
def object_cache_key
|
284
|
-
if object.respond_to?(:
|
286
|
+
if object.respond_to?(:cache_key_with_version)
|
287
|
+
object.cache_key_with_version
|
288
|
+
elsif object.respond_to?(:cache_key)
|
285
289
|
object.cache_key
|
286
290
|
elsif (serializer_cache_key = (serializer_class._cache_key || serializer_class._cache_options[:key]))
|
287
291
|
object_time_safe = object.updated_at
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveModel
|
2
4
|
class Serializer
|
3
5
|
# @api private
|
@@ -7,11 +9,12 @@ module ActiveModel
|
|
7
9
|
delegate :collection?, to: :reflection
|
8
10
|
|
9
11
|
def reflection_options
|
10
|
-
@reflection_options ||= reflection.options.
|
12
|
+
@reflection_options ||= reflection.options.select { |k, _| REFLECTION_OPTIONS.include?(k) }
|
11
13
|
end
|
12
14
|
|
13
15
|
def object
|
14
|
-
@object
|
16
|
+
return @object if defined?(@object)
|
17
|
+
@object = reflection.value(
|
15
18
|
association_options.fetch(:parent_serializer),
|
16
19
|
association_options.fetch(:include_slice)
|
17
20
|
)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveModelSerializers
|
2
4
|
module Adapter
|
3
5
|
UnknownAdapterError = Class.new(ArgumentError)
|
@@ -35,7 +37,7 @@ module ActiveModelSerializers
|
|
35
37
|
|
36
38
|
# @return [Array<Symbol>] list of adapter names
|
37
39
|
def adapters
|
38
|
-
adapter_map.keys.sort
|
40
|
+
adapter_map.keys.sort!
|
39
41
|
end
|
40
42
|
|
41
43
|
# Adds an adapter 'klass' with 'name' to the 'adapter_map'
|