lib/cached_resource/caching.rb in cached_resource-2.1.2 vs lib/cached_resource/caching.rb in cached_resource-2.1.3

- old
+ new

@@ -79,11 +79,13 @@ # Read a entry from the cache for the given key. # The key is processed to make sure it is valid. def cache_read(key) key = cache_key(Array(key)) unless key.is_a? String - object = cached_resource.cache.read(key).try(:dup) + object = cached_resource.cache.read(key).try do |cache| + cache.dup.tap { |o| o.instance_variable_set(:@persisted, cache.persisted?) if cache.respond_to?(:persisted?) } + end object && cached_resource.logger.info("#{CachedResource::Configuration::LOGGER_PREFIX} READ #{key}") object end # Write an entry to the cache for the given key and value. @@ -100,6 +102,6 @@ "#{name.parameterize.gsub("-", "/")}/#{arguments.join('/')}".downcase end end end -end \ No newline at end of file +end