tacky 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/lib/tacky.rb +6 -1
- data/tacky.gemspec +1 -1
- data/test/test_tacky.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a6083f7897cb350eae36809a0638caa2b261bc77e07eae5a986452ce1d1b07d
|
4
|
+
data.tar.gz: b99c5fc9d58d608df08ca0be72ad03d0bc1219be4067cf22be104203d1c8490c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd03f573aa87f95143ba4775e282fa4c24e2ba2cc55b2041643466beed8e92cea7362d635dfc4390ba25a21253abfa4292084745ae36ffa338af48ddc82798e0
|
7
|
+
data.tar.gz: e20430b55d31f738be6fdc55e522759a49b7179f4717832745f555d51b2c3a1c9d4148b60620b9ca7a647735c8474ccfe9f7f21e30d488f362b89f835c0f814c
|
data/lib/tacky.rb
CHANGED
@@ -34,6 +34,9 @@
|
|
34
34
|
class Tacky
|
35
35
|
undef_method :send
|
36
36
|
|
37
|
+
# Deep nesting will stop at these classes.
|
38
|
+
STOP = [Numeric, NilClass, TrueClass, FalseClass, Array, Hash].freeze
|
39
|
+
|
37
40
|
def initialize(origin, deep: false)
|
38
41
|
@origin = origin
|
39
42
|
@cache = {}
|
@@ -47,7 +50,9 @@ class Tacky
|
|
47
50
|
@cache[args] = @origin.__send__(*args) do |*a|
|
48
51
|
yield(*a) if block_given?
|
49
52
|
end
|
50
|
-
@
|
53
|
+
if @deep && STOP.none? { |t| @cache[args].is_a?(t) }
|
54
|
+
@cache[args] = Tacky.new(@cache[args], deep: @deep)
|
55
|
+
end
|
51
56
|
end
|
52
57
|
@cache[args]
|
53
58
|
end
|
data/tacky.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.rubygems_version = '2.3.3'
|
32
32
|
s.required_ruby_version = '>=2.3'
|
33
33
|
s.name = 'tacky'
|
34
|
-
s.version = '0.3.
|
34
|
+
s.version = '0.3.2'
|
35
35
|
s.license = 'MIT'
|
36
36
|
s.summary = 'Primitive Object Memoization for Ruby'
|
37
37
|
s.description = 'Decorate your existing Ruby object with Tacky
|
data/test/test_tacky.rb
CHANGED