multi_fetch_fragments 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/multi_fetch_fragments.rb +6 -11
- metadata +1 -1
@@ -41,23 +41,15 @@ module MultiFetchFragments
|
|
41
41
|
|
42
42
|
non_cached_results = []
|
43
43
|
|
44
|
-
# sequentially render any non-cached objects remaining
|
44
|
+
# sequentially render any non-cached objects remaining
|
45
45
|
if @collection.any?
|
46
46
|
|
47
47
|
collection_objects_clone = @collection.clone
|
48
48
|
|
49
49
|
non_cached_results = @template ? collection_with_template : collection_without_template
|
50
|
-
|
51
|
-
non_cached_results.each_with_index do |item, index|
|
52
|
-
|
53
|
-
collection_object = collection_objects_clone[index]
|
54
|
-
key = collection_to_keys_map[collection_object]
|
55
|
-
|
56
|
-
Rails.cache.write(key, item)
|
57
|
-
end
|
58
50
|
end
|
59
51
|
|
60
|
-
#
|
52
|
+
# sort the result according to the keys that were fed in, cache the non-cached results
|
61
53
|
keys_to_collection_map.each do |key, value|
|
62
54
|
|
63
55
|
# was it in the cache?
|
@@ -65,7 +57,10 @@ module MultiFetchFragments
|
|
65
57
|
if cached_value
|
66
58
|
results << result_hash[key]
|
67
59
|
else
|
68
|
-
|
60
|
+
non_cached_result = non_cached_results.shift
|
61
|
+
Rails.cache.write(key, non_cached_result)
|
62
|
+
|
63
|
+
results << non_cached_result
|
69
64
|
end
|
70
65
|
end
|
71
66
|
|