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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee77b7b8979ba7c58c691afab738e48a3543e58c9f388fb4d3d7c9f3de97675a
4
- data.tar.gz: df9dc0977027d9a7644e32ffa515930cd25d3fb841f3fd16146bc09bfa5bbd02
3
+ metadata.gz: d8cbaf0bd7f78a40b8b5a1583c0bf075877e7158c04c7f7295661e497cfbc42d
4
+ data.tar.gz: 425adc58abfa6e92a3d1e4a599db1b5f39df7da1aa4f40b025e25c71b48a86ad
5
5
  SHA512:
6
- metadata.gz: 2ec4ea5bc54cc96aeeeb32c4f576b39bf5eae8563773cba5bfabc0150426e4f49f872e9ebaa1934046b44d036ea1f565a41d99337f6f86962d6390371b073602
7
- data.tar.gz: b632307a64a67e96144c51adabaf8edcbd2cd0cf72fcb602148e27e9b96bc2999aaf03a7c597b5b9e7af045ec75366851b851ed4f7ed7a892828e2a0d7b9e3e4
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: :f")
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lab42
4
4
  class DiggyMethods
5
- VERSION = "0.1.3"
5
+ VERSION = "0.1.4"
6
6
  end
7
7
  end
8
8
  # SPDX-License-Identifier: Apache-2.0
@@ -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
- found = @data.fetch(name)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lab42_diggy_methods
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober