tonsser_hash_utils 1.0.5 → 1.0.6

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: 8cb49e652eda07aca3dcc8fb15a6837951e2c397bbd11344ca30e9b6d43a70b3
4
- data.tar.gz: bc0db979b26c1aca79c2fb20fe0c8fc2a976f8d4e80d7e62a2bebe6db5310f61
3
+ metadata.gz: c0ca8eee5e33287735e7ff0dd2378f23c6ae751429d7446a329f39ac90889cb8
4
+ data.tar.gz: f93694d8ffa36d6dd3d5685399c0010b984583318e4bc4d7fc5c413ba3a29586
5
5
  SHA512:
6
- metadata.gz: 906daf636af381752b35ca788b2d74732a7194387520db33e3dbed341845a82226843261138b965b3d9eea45ecf482431525d8081b877971fc824ad536f5fd3a
7
- data.tar.gz: 732fad0ba14711ba4c56980b09632db9844d3de4c3e9c57ec41e6efe0b7780a13c3b4e368662c8ca7b9b51cd7b7fb7601157902d62470ce96fff0254559d3610
6
+ metadata.gz: 316f000845afcd76cbf374498feba119f39bbd13796c6e1cba6ed6189b813428e7869370fd9e1a78abb5c1be0600922f161a1b4c4967cd958da20ec1877297dc
7
+ data.tar.gz: a8b21521b44c1b4b6e15c775e9ddfb747a1be2a9eba443fee10ebd06e75d92b9f03756af1c5ffffab2ab92909c85cd5c2a0cb87284e3bba716c9c78d5032908a
@@ -15,7 +15,11 @@ class HashWithQuickAccess
15
15
  else
16
16
  fail KeyError, "key :#{key} was not found"
17
17
  end
18
- define_singleton_method(key) { value }
18
+
19
+ if !hash.respond_to?(key)
20
+ define_singleton_method(key) { value }
21
+ end
22
+
19
23
  value
20
24
  end
21
25
 
@@ -1,3 +1,3 @@
1
1
  module TonsserHashUtils
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.6"
3
3
  end
@@ -85,6 +85,16 @@ describe HashWithQuickAccess do
85
85
  expect(hash.methods - Object.new.methods).to include :a
86
86
  end
87
87
 
88
+ it "doesn't memoize Hash methods" do
89
+ pp (Hash.new.methods - Object.new.methods).sort
90
+ raise
91
+
92
+ hash = HashWithQuickAccess.new(a: 1)
93
+
94
+ expect(hash.key?(:a)).to eq true
95
+ expect(hash.key?(:a)).to eq true
96
+ end
97
+
88
98
  it "can monkey patch Hash with a convenience method" do
89
99
  HashWithQuickAccess.add_convenience_method_to_hash!
90
100
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tonsser_hash_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Pedersen