autobots 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/autobots/helpers/caching.rb +11 -3
- data/lib/autobots/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5276029a0a189a4e7a067a5d47e7dbc5990eccd
|
4
|
+
data.tar.gz: eb89fab64980725b4e2502ccf67d63b1afd12f46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 860b12863e969a7441f1f6afc87457cea2d48c5978f3ec7e9bd29d7e2e3e3f32a5ca08c7dcdf4e9389d32a775faf58179784e449519b126e779c5129e93719ca
|
7
|
+
data.tar.gz: d8d7efc2073ad9562c71089d3d9404a7ed38295ec2e74de19ae8b8548b7942c539a6e426685284787a2d6cf690c3c5df57eb2d59d3b8d241850a46174feac35e
|
@@ -1,15 +1,23 @@
|
|
1
1
|
module Autobots
|
2
2
|
module Helpers
|
3
3
|
module Caching
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
4
6
|
def initialize(_, options = {})
|
5
7
|
super
|
6
|
-
|
8
|
+
self.cache = options[:cache] if options.has_key?(:cache)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.prepended(klass)
|
12
|
+
klass.class_eval do
|
13
|
+
class_attribute :cache
|
14
|
+
end
|
7
15
|
end
|
8
16
|
|
9
17
|
def data
|
10
18
|
return @data if defined?(@data)
|
11
19
|
|
12
|
-
if
|
20
|
+
if cache
|
13
21
|
key_proc = options.fetch(:cache_key) do
|
14
22
|
method(:cache_key)
|
15
23
|
end
|
@@ -19,7 +27,7 @@ module Autobots
|
|
19
27
|
end
|
20
28
|
|
21
29
|
# misses: { key => obj }
|
22
|
-
@data = BulkCacheFetcher.new(
|
30
|
+
@data = BulkCacheFetcher.new(cache).fetch(identifiers) do |misses|
|
23
31
|
roll_out(misses.values)
|
24
32
|
end
|
25
33
|
else
|
data/lib/autobots/version.rb
CHANGED