memorandum 1.0.0 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffc77bb42f97cf3fc5d6ab97ab7f349ef86ba27b
4
- data.tar.gz: edb54cbad95a111deb2d224ad39b7c917e40ffd0
3
+ metadata.gz: 5bfe179f47a16d23b56f968028744535d7a4734c
4
+ data.tar.gz: 0fe7e118073c681712d9c982c3bea5c3d60a09e6
5
5
  SHA512:
6
- metadata.gz: 947d899367bc2478168a7aeec22c049b7b1013097a143ca00629480f4c4fc615da9c5424024a319fd086bd904002b0805bb480203de65a38eeeca9d51483dbeb
7
- data.tar.gz: 06c287798d53465af8c4c4486b0c202071d7013415f4350326d6d9b3d941776d3c11ae962a8419459f2a96f677466e99652b860d4b0580eee5776bf5f0aed442
6
+ metadata.gz: ac62063b5a52e2876747d124f7e23ba5b45b11bde844edeeecfa9114cb91bce8c379bbb3e715b8ab742403f61ccae2055f2b935e3df6ce01d2028e36903c7a7e
7
+ data.tar.gz: 31983920547e5a54d04c312ae1817f43e9699bbe2e44167f02c2e00b2e221e1d35816689b74c55b4eea0c2f05633077a70d2e8431cbc62ea816762d84b930ea6
data/lib/memorandum.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  module Memorandum
2
- def memo name, &block
3
- memoized_values = "@memoized_values_for_#{name}"
2
+ def memo name, &memoizer
4
3
  memoized_statuses = "@memoized_statuses_for_#{name}"
4
+ memoized_values = "@memoized_values_for_#{name}"
5
+ memoizer_name = "memoizer_for_#{name}"
6
+
7
+ define_method memoizer_name, &memoizer
5
8
 
6
9
  send :define_method, name do |*args|
7
10
  statuses = instance_variable_get(memoized_statuses) \
@@ -11,7 +14,7 @@ module Memorandum
11
14
  || instance_variable_set(memoized_values, Hash[])
12
15
 
13
16
  unless statuses[args]
14
- values[args] = block.call *args
17
+ values[args] = send memoizer_name, *args
15
18
  statuses[args] = true
16
19
  end
17
20
  values[args]
@@ -1,3 +1,3 @@
1
1
  module Memorandum
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memorandum
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Lude