memo-it 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/README.md +1 -1
- data/lib/memo/it.rb +4 -3
- 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: a8f78c7a50e8cbad98d26701c1e0f28a65787594
|
4
|
+
data.tar.gz: f43cb631b0416a4188c51f11c301d3db6a0f7599
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05bdef9d4e2e040ac5906fe6b8cd879a337e92ebe591400abfa492a2a0b8663c44b8734edc179d3e7d850ea549488828c35d5025abf30649d19ed2b1e25b04bc
|
7
|
+
data.tar.gz: 89d151fee8ec8a53ee5fb3fc8e6fc8509bc44ed6422e583b04cc1180203e19e2b48a652cbe69693a3fac0be6053d987b1345986623275287de01db5dee61f0a0
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Memo::It
|
2
2
|
|
3
|
-
Clever memoization helper that uses Ruby internals instead of meta-programming.
|
3
|
+
Clever memoization helper that uses Ruby internals instead of meta-programming. [![Build Status](https://travis-ci.org/phoet/memo-it.svg?branch=master)](https://travis-ci.org/phoet/memo-it)
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
data/lib/memo/it.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module Memo
|
2
|
-
VERSION = '0.1.
|
2
|
+
VERSION = '0.1.2'
|
3
3
|
module It
|
4
4
|
def memo(&block)
|
5
5
|
keys = block.source_location
|
6
|
-
keys << block.binding.local_variables.map { |name| [name, block.binding.local_variable_get(name)
|
6
|
+
keys << block.binding.local_variables.map { |name| [name, block.binding.local_variable_get(name)] }
|
7
|
+
keys = keys.flatten.map(&:to_s)
|
7
8
|
|
8
9
|
@_memo_it ||= {}
|
9
|
-
@_memo_it[keys] if @_memo_it.key? keys
|
10
|
+
return @_memo_it[keys] if @_memo_it.key? keys
|
10
11
|
@_memo_it[keys] = yield
|
11
12
|
end
|
12
13
|
end
|