mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Merge pull request #1687 from bf4/lazyify_calculating_caller_digest
Lazify calculating caller file digest until used
This commit is contained in:
commit
7485c8487e
@ -8,6 +8,7 @@ Breaking changes:
|
|||||||
- [#1574](https://github.com/rails-api/active_model_serializers/pull/1574) Default key case for the JsonApi adapter changed to dashed. (@remear)
|
- [#1574](https://github.com/rails-api/active_model_serializers/pull/1574) Default key case for the JsonApi adapter changed to dashed. (@remear)
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
- [#1687](https://github.com/rails-api/active_model_serializers/pull/1687) Only calculate `_cache_digest` (in `cache_key`) when `skip_digest` is false. (@bf4)
|
||||||
- [#1647](https://github.com/rails-api/active_model_serializers/pull/1647) Restrict usage of `serializable_hash` options
|
- [#1647](https://github.com/rails-api/active_model_serializers/pull/1647) Restrict usage of `serializable_hash` options
|
||||||
to the ActiveModel::Serialization and ActiveModel::Serializers::JSON interface. (@bf4)
|
to the ActiveModel::Serialization and ActiveModel::Serializers::JSON interface. (@bf4)
|
||||||
- [#1645](https://github.com/rails-api/active_model_serializers/pull/1645) Transform keys referenced in values. (@remear)
|
- [#1645](https://github.com/rails-api/active_model_serializers/pull/1645) Transform keys referenced in values. (@remear)
|
||||||
|
|||||||
@ -18,8 +18,9 @@ module ActiveModel
|
|||||||
# force
|
# force
|
||||||
# race_condition_ttl
|
# race_condition_ttl
|
||||||
# Passed to ::_cache as
|
# Passed to ::_cache as
|
||||||
# serializer._cache.fetch(cache_key, @klass._cache_options)
|
# serializer.cache_store.fetch(cache_key, @klass._cache_options)
|
||||||
serializer.class_attribute :_cache_digest # @api private : Generated
|
# Passed as second argument to serializer.cache_store.fetch(cache_key, self.class._cache_options)
|
||||||
|
serializer.class_attribute :_cache_digest_file_path # @api private : Derived at inheritance
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -42,7 +43,12 @@ module ActiveModel
|
|||||||
def inherited(base)
|
def inherited(base)
|
||||||
super
|
super
|
||||||
caller_line = caller[1]
|
caller_line = caller[1]
|
||||||
base._cache_digest = digest_caller_file(caller_line)
|
base._cache_digest_file_path = caller_line
|
||||||
|
end
|
||||||
|
|
||||||
|
def _cache_digest
|
||||||
|
return @_cache_digest if defined?(@_cache_digest)
|
||||||
|
@_cache_digest = digest_caller_file(_cache_digest_file_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Hashes contents of file for +_cache_digest+
|
# Hashes contents of file for +_cache_digest+
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user