memo-it 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/lib/memo/it.rb +11 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af982b8ebf877a0f128499d126d2b40bf407894a
|
4
|
+
data.tar.gz: f4c35d3df4468bb778eb075b2fd8ff640313e676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 807f598a93993f69e680e2b9b33f01881e6c378ca126cccdba0cef8f8f4e1d4fd14324b6a7c9369cf60a36706ead8859c47eb2fe32796ed37d685cb2682d894e
|
7
|
+
data.tar.gz: c46ce4c40fb9d19da3ff5c34ed76cbce9ba51f40b83dc21dc650638feeb1789c7846a81bf7a186b5540551538aa8a29da7cef1b529a872d61e12985245527625
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
-
## 0.3.1
|
3
|
+
## 0.3.2 ([list of commits](https://github.com/phoet/memo-it/compare/v0.3.1...v0.3.2))
|
4
|
+
|
5
|
+
* cache on the class level (see [issue #7](https://github.com/phoet/memo-it/pull/9) for details)
|
6
|
+
|
7
|
+
## 0.3.1 ([list of commits](https://github.com/phoet/memo-it/compare/v0.3.0...v0.3.1))
|
4
8
|
|
5
9
|
* simplify key generation (see [issue #7](https://github.com/phoet/memo-it/pull/7) for details)
|
6
10
|
|
data/lib/memo/it.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Memo
|
2
|
-
VERSION = '0.3.
|
2
|
+
VERSION = '0.3.2'
|
3
3
|
|
4
4
|
@enabled = true
|
5
5
|
|
@@ -15,6 +15,14 @@ module Memo
|
|
15
15
|
@enabled = false
|
16
16
|
end
|
17
17
|
|
18
|
+
def self.cache
|
19
|
+
@cache ||= {}
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.clear
|
23
|
+
cache.clear
|
24
|
+
end
|
25
|
+
|
18
26
|
module It
|
19
27
|
def memo(only: [], except: [], &block)
|
20
28
|
only = Array(only)
|
@@ -29,9 +37,8 @@ module Memo
|
|
29
37
|
keys = block.source_location
|
30
38
|
keys << key_names.flat_map { |name| [name, block.binding.local_variable_get(name)] }
|
31
39
|
|
32
|
-
|
33
|
-
|
34
|
-
@_memo_it[keys] = yield
|
40
|
+
return Memo.cache[keys] if Memo.enabled? && Memo.cache.key?(keys)
|
41
|
+
Memo.cache[keys] = yield
|
35
42
|
end
|
36
43
|
end
|
37
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memo-it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- phoet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|