lib/cached_resource/caching.rb in cached_resource-5.1.2 vs lib/cached_resource/caching.rb in cached_resource-5.1.3

- old
+ new

@@ -84,12 +84,11 @@ # Read a entry from the cache for the given key. def cache_read(key) object = cached_resource.cache.read(key).try do |json_cache| - # In older version JSON can't deserialize 'null' to nil - json = json_cache == 'null' ? nil : JSON.parse(json_cache, :symbolize_names => true) + json = ActiveSupport::JSON.decode(json_cache) unless json.nil? cache = json_to_object(json) if cache.is_a? Enumerable restored = cache.map { |record| full_dup(record) } @@ -132,12 +131,12 @@ end def json_to_object(json) if json.is_a? Array json.map { |attrs| - self.new(attrs[:object], attrs[:persistence]) } + self.new(attrs["object"], attrs["persistence"]) } else - self.new(json[:object], json[:persistence]) + self.new(json["object"], json["persistence"]) end end def object_to_json(object) if object.is_a? Enumerable