depth 0.4.0 → 0.4.1

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
  SHA1:
3
- metadata.gz: 85d067842e7799d193a25834e13a66d7b8fd7375
4
- data.tar.gz: e6af288638c9e95b1a9e3d3fd9a245a05ce17320
3
+ metadata.gz: 020e097f5dbedcd06e1ae89f478d5544b672cb7e
4
+ data.tar.gz: 148d7af877ce2e13d3169e6cf2431127f3f9c473
5
5
  SHA512:
6
- metadata.gz: 207ae9111a988453a18d33b25c5ba1d70e0249d655874377de02d4f82b6b30b86b9b57b3778a03052b20b828b0f1bd8f859dd601a765937a5d4dd6b4ac3deba8
7
- data.tar.gz: 012ac2126a5aa29cacf5806fef20cc0686378715b708c5decdcf9d57c975ba78b0c90869449476ef94d52e0486721caef036c29eff93f7c17d10b3ef0a121c6c
6
+ metadata.gz: 17a7c92001978b81e328f45a5e764780804e07a0351d9e7f7d6bf83d217d1670c020be962c7c12889c26feba845487b105f8f04530a12f457a73b5038dde6200
7
+ data.tar.gz: f4d5828f974630b8f690950537d769ee115d0eaa65310f4029772eab79971d459eafb50307df289af34b564f6adb4d7f97bb131db5afc430d1b2f81e4dee7882
@@ -48,9 +48,12 @@ module Depth
48
48
  t.next(route_el.key)
49
49
  end
50
50
  }.object
51
+
52
+ return default if parent.nil?
53
+
51
54
  original_key = route.last.key
52
55
  transformed_key = key_transformer.call(parent, route.last.key)
53
- object = parent ? next_proc.call(parent, transformed_key, original_key) : nil
56
+ object = next_proc.call(parent, transformed_key, original_key)
54
57
  return object unless object.nil?
55
58
  return creation_proc.call(parent, transformed_key, default, original_key) if create && default
56
59
  default
@@ -1,3 +1,3 @@
1
1
  module Depth
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
@@ -193,6 +193,13 @@ module Depth
193
193
  end
194
194
  end
195
195
 
196
+ context 'with a missing route should return nil' do
197
+ it 'should return nil' do
198
+ route = ['$yo', 0, '$thing', 3, '434']
199
+ expect(subject.find(route)).to be_nil
200
+ end
201
+ end
202
+
196
203
  it 'should let me find an existing value' do
197
204
  route = [['$and', :array], [0, :hash],
198
205
  ['#weather', :hash], ['something', :array]]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: depth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-09 00:00:00.000000000 Z
11
+ date: 2016-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler