Class: Api::V5::LocationSerializer
- Inherits:
-
BaseSerializer
- Object
- ActiveModel::Serializer
- ApplicationSerializer
- BaseSerializer
- Api::V5::LocationSerializer
- Defined in:
- app/serializers/api/v5/location_serializer.rb
Overview
typed: ignore frozen_string_literal: true
Instance Method Summary collapse
-
#object_cache_key ⇒ Object
Overrides the default cache key generation method.
Methods inherited from BaseSerializer
#full_attachment_url, #safe_translation_attr
Methods inherited from ApplicationSerializer
decorate_attributes, decorator
Instance Method Details
#object_cache_key ⇒ Object
Overrides the default cache key generation method. Ref. github.com/rails-api/active_model_serializers/blob/0-10-stable/lib/active_model/serializer/concerns/caching.rb
Need to overrides the default cache key generation method, because the current cache key generation in the application_serializer is returns the same object, even though the object has been updated.
27 28 29 30 31 32 |
# File 'app/serializers/api/v5/location_serializer.rb', line 27 def object_cache_key object_time_safe = object.updated_at object_time_safe = object_time_safe.strftime('%Y%m%d%H%M%S%9N') if object_time_safe.respond_to?(:strftime) "#{self.class.name}:#{object.id}:#{I18n.locale}:#{object_time_safe}:#{CityHash.hash32()}:#{object..cache_key}" end |