Sha256: 5a77620949d8fa88345da39f653d33e89b902520984dfaf13b7fd03573987945
Contents?: true
Size: 812 Bytes
Versions: 12
Compression:
Stored size: 812 Bytes
Contents
module ActiveModel class Serializer module Caching def to_json(*args) if caching_enabled? key = expand_cache_key([self.class.to_s.underscore, cache_key, 'to-json']) cache.fetch key do super end else super end end def serialize(*args) if caching_enabled? key = expand_cache_key([self.class.to_s.underscore, cache_key, 'serialize']) cache.fetch key do serialize_object end else serialize_object end end private def caching_enabled? perform_caching && cache && respond_to?(:cache_key) end def expand_cache_key(*args) ActiveSupport::Cache.expand_cache_key(args) end end end end
Version data entries
12 entries across 12 versions & 1 rubygems