lib/wcc/media/cacheable.rb in wcc-media-client-0.4.11 vs lib/wcc/media/cacheable.rb in wcc-media-client-0.4.12
- old
+ new
@@ -8,9 +8,18 @@
(headers&.fetch('Etag', nil) if respond_to?(:headers))
key ||= WCC::Media::Cacheable.hash_cache_key(raw)
@cache_key = "#{self.class.name}/#{key}"
end
+ def last_modified
+ return @last_modified if @last_modified
+
+ last_modified =
+ (headers&.fetch('Last-Modified', nil) if respond_to?(:headers))
+ @last_modified = Time.parse(last_modified) if last_modified && /\S/.match(last_modified)
+ end
+ alias_method :updated_at, :last_modified
+
def self.hash_cache_key(hash)
Digest::SHA1.hexdigest(Marshal.dump(hash))
end
end
end
\ No newline at end of file