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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03d965839596661b75b8176fa89c5d77339a8c743c7165aa446823e958f74cf4
4
- data.tar.gz: ec5baa6265880b4dfd58f248ef37460836ae4a9e73f6a4b148cad1b5ccd1199d
3
+ metadata.gz: 6a6083f7897cb350eae36809a0638caa2b261bc77e07eae5a986452ce1d1b07d
4
+ data.tar.gz: b99c5fc9d58d608df08ca0be72ad03d0bc1219be4067cf22be104203d1c8490c
5
5
  SHA512:
6
- metadata.gz: c60aa81aa2308a87af1411ce40857ced608f1a85489fd8a038953a6b4f2b5dcf9c049ecfd38ac6c45a4c62f429953cb1b9111a174d8c40cf7e9fc4914f25f174
7
- data.tar.gz: 7ca17f05bdf02a5f46a2ea1b9b12463b239000d7e13c400987a56109514782022e671bb4c3d019ded16e5c41e836345b8381c714cf08b5568b7220b819b20814
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
- @cache[args] = Tacky.new(@cache[args], deep: @deep) if @deep
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.1'
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
@@ -51,6 +51,7 @@ class TackyTest < Minitest::Test
51
51
  end
52
52
  bar = Tacky.new(foo, deep: true)
53
53
  first = bar.child.value
54
+ assert(first.is_a?(Numeric))
54
55
  assert(bar.child.value == first)
55
56
  end
56
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tacky
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
  - Yegor Bugayenko