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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -1
  3. data/lib/memo/it.rb +11 -4
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c219d9d1f53efd7dcb2686f35b8ad1627764aa3
4
- data.tar.gz: 0b539381c33dd4037cfe3425055b5ead557ba47c
3
+ metadata.gz: af982b8ebf877a0f128499d126d2b40bf407894a
4
+ data.tar.gz: f4c35d3df4468bb778eb075b2fd8ff640313e676
5
5
  SHA512:
6
- metadata.gz: c64c5ce79094046b63f68d368c4da21583406e6fd27476508efc865d91084383bcfe070c435f6063bed3f819bcc35d2b5b38d014aaef999db9114f2a81a8a9d5
7
- data.tar.gz: 14cb63e98f8431a9051de9d8fb11a43a3ccab8af6ae11cd6ca63244d9540707ed30cfa0aeb5a5db3bf92058b4626525060b934153d2329aaf52a45449eabae15
6
+ metadata.gz: 807f598a93993f69e680e2b9b33f01881e6c378ca126cccdba0cef8f8f4e1d4fd14324b6a7c9369cf60a36706ead8859c47eb2fe32796ed37d685cb2682d894e
7
+ data.tar.gz: c46ce4c40fb9d19da3ff5c34ed76cbce9ba51f40b83dc21dc650638feeb1789c7846a81bf7a186b5540551538aa8a29da7cef1b529a872d61e12985245527625
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  module Memo
2
- VERSION = '0.3.1'
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
- @_memo_it ||= {}
33
- return @_memo_it[keys] if Memo.enabled? && @_memo_it.key?(keys)
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.1
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-01-31 00:00:00.000000000 Z
11
+ date: 2017-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler