multi_fetch_fragments 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/multi_fetch_fragments.rb +6 -11
  2. 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, and cache them
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
- # re-sort the result according to the keys that were fed in
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
- results << non_cached_results.shift
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_fetch_fragments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: