memist 2.0.1 → 2.0.2
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -2
- data.tar.gz.sig +0 -0
- data/lib/memist/class_methods.rb +9 -5
- data/lib/memist/instance_methods.rb +13 -0
- data/lib/memist/version.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8598567f17d0d1529feec01f833d363504f0f5d2a6779b02be1981358d5c9bda
|
4
|
+
data.tar.gz: 6133b314f773eacc680c23cd9892b7dbfd90c67d4022da4a730154f27a8d949d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3fe4a42e21a828bbc0cf4296c724c417c35a604757b65f88652c295fe70623fe6fbebbdb35b4a8e03cdc5ffa81f137057f69b661487778e9fecd38f9c2423a9
|
7
|
+
data.tar.gz: 0ac546190aa46665630906ddfeafa08d3aca45d059097499d1049422c6498eea8a4af8dd38986873dff28367c344c5aaa91e3ad637e67a736c604b74dbddff46
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
*ܰ�^E0!Y�Ϫ.C �⣣:D��U���b����x�&n�`�A��O�~�i���'�����Ra"��d'�l�a"�$1.5���M���y��-���D
|
2
|
+
h
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/memist/class_methods.rb
CHANGED
@@ -13,12 +13,16 @@ module Memist
|
|
13
13
|
end
|
14
14
|
|
15
15
|
define_method "#{method}_with_memoization" do |arg = nil|
|
16
|
-
|
17
|
-
|
18
|
-
@memoized_values[method]
|
16
|
+
if memoize?
|
17
|
+
@memoized_values ||= Hash.new { |hash, key| hash[key] = {} }
|
18
|
+
if @memoized_values.key?(method) && @memoized_values[method].key?(arg)
|
19
|
+
@memoized_values[method][arg]
|
20
|
+
else
|
21
|
+
value = send("#{method}_without_memoization", *arg)
|
22
|
+
@memoized_values[method][arg] = value
|
23
|
+
end
|
19
24
|
else
|
20
|
-
|
21
|
-
@memoized_values[method][arg] = value
|
25
|
+
send("#{method}_without_memoization", *arg)
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
@@ -27,5 +27,18 @@ module Memist
|
|
27
27
|
def memoized?(method)
|
28
28
|
!!(@memoized_values && @memoized_values.include?(method.to_sym))
|
29
29
|
end
|
30
|
+
|
31
|
+
def without_memoization
|
32
|
+
Thread.current[:without_memoization] ||= 0
|
33
|
+
Thread.current[:without_memoization] += 1
|
34
|
+
yield
|
35
|
+
ensure
|
36
|
+
Thread.current[:without_memoization] -= 1
|
37
|
+
end
|
38
|
+
|
39
|
+
def memoize?
|
40
|
+
Thread.current[:without_memoization].nil? ||
|
41
|
+
Thread.current[:without_memoization] <= 0
|
42
|
+
end
|
30
43
|
end
|
31
44
|
end
|
data/lib/memist/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
3wUJNGnT5XYq+qvTqmjkTSTfdGvZCM63C6bGdN5CAyMokGOOatGqyCMAONolWnfC
|
31
31
|
gm3t2GWWrxY=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2019-
|
33
|
+
date: 2019-12-02 00:00:00.000000000 Z
|
34
34
|
dependencies: []
|
35
35
|
description: A Ruby Memoization Helper
|
36
36
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|