lab42_diggy_methods 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/lab42/diggy_methods/version.rb +1 -1
- data/lib/lab42/diggy_methods.rb +5 -3
- 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: d8cbaf0bd7f78a40b8b5a1583c0bf075877e7158c04c7f7295661e497cfbc42d
|
4
|
+
data.tar.gz: 425adc58abfa6e92a3d1e4a599db1b5f39df7da1aa4f40b025e25c71b48a86ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 331c2a205746618e0e868b110da0128296ab63b5f8047a1935f0fee27cf22a0b25d8da7760324f8e350f984a8044378ff194f7853d7152a2c3b7d76c6f29da3b
|
7
|
+
data.tar.gz: 577292e722386233c97d435cf6bfbac4fbcb3111179facf7dda176c45638dae6d962d8141d1af9f8363b38e2d64c971a9f50a1e9fcf2d1b7ed5191eeabd544a1
|
data/README.md
CHANGED
@@ -60,7 +60,7 @@ And that works for leave nodes too of course
|
|
60
60
|
|
61
61
|
And in case of missing keys
|
62
62
|
```ruby
|
63
|
-
expect{ diggy.b.d.f }.to raise_error(KeyError, "key not found:
|
63
|
+
expect{ diggy.b.d.f }.to raise_error(KeyError, "key not found: b.d.f")
|
64
64
|
```
|
65
65
|
|
66
66
|
If we access unknown keys we get the usual `KeyError` error, however we must not pass, nonhashable data
|
data/lib/lab42/diggy_methods.rb
CHANGED
@@ -12,8 +12,9 @@ module Lab42
|
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
-
def initialize(a=nil, **data_)
|
15
|
+
def initialize(a=nil, __key_chain__: [], **data_)
|
16
16
|
@data = _make_data_from_args(a, data_)
|
17
|
+
@keychain = __key_chain__
|
17
18
|
end
|
18
19
|
|
19
20
|
def _make_data_from_args(a, data_)
|
@@ -51,14 +52,15 @@ module Lab42
|
|
51
52
|
|
52
53
|
def _maybe_make_diggy(found)
|
53
54
|
if found.respond_to?(:to_h)
|
54
|
-
self.class.new(**found)
|
55
|
+
self.class.new(**found, __key_chain__: @keychain)
|
55
56
|
else
|
56
57
|
found
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
60
61
|
def _method_missing_try_descend(name)
|
61
|
-
|
62
|
+
@keychain << name
|
63
|
+
found = @data.fetch(name) { raise KeyError, "key not found: #{@keychain.join(".")}" }
|
62
64
|
if Array === found
|
63
65
|
_make_diggy_array(found)
|
64
66
|
else
|