Module: ActiveModelSerializers::Model::Caching

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_model_serializers/model/caching.rb

Instance Method Summary collapse

Instance Method Details

#cache_keyObject

Defaults to the downcased model name and updated_at



13
14
15
16
17
18
# File 'lib/active_model_serializers/model/caching.rb', line 13

def cache_key
  ActiveSupport::Cache.expand_cache_key([
    self.class.model_name.name.downcase,
    "#{id}-#{updated_at.strftime('%Y%m%d%H%M%S%9N')}"
  ].compact)
end

#updated_atObject

Defaults to the time the serializer file was modified.



21
22
23
# File 'lib/active_model_serializers/model/caching.rb', line 21

def updated_at
  defined?(@updated_at) ? @updated_at : File.mtime(__FILE__)
end