depth 0.4.1 → 0.4.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
  SHA1:
3
- metadata.gz: 020e097f5dbedcd06e1ae89f478d5544b672cb7e
4
- data.tar.gz: 148d7af877ce2e13d3169e6cf2431127f3f9c473
3
+ metadata.gz: a2d275d97521a90922bfd87e95208fcb99cbf836
4
+ data.tar.gz: d31499f6313426697c37222541c3559b91e9cc18
5
5
  SHA512:
6
- metadata.gz: 17a7c92001978b81e328f45a5e764780804e07a0351d9e7f7d6bf83d217d1670c020be962c7c12889c26feba845487b105f8f04530a12f457a73b5038dde6200
7
- data.tar.gz: f4d5828f974630b8f690950537d769ee115d0eaa65310f4029772eab79971d459eafb50307df289af34b564f6adb4d7f97bb131db5afc430d1b2f81e4dee7882
6
+ metadata.gz: 524e6b44d60c2fc130f83b81eb6b200b735692ab3c6b0a05ce0f908fd30047b038c5b3623f280e8b42d64ffaa59bb25a96e197c8fc6509895e3ee5f6bf5966a7
7
+ data.tar.gz: 12e3c45354a6d046a40496e0a01f4ea2fdb8be0b24f5ae0b18b3d1a13cd4eb25dbbad1d1465ef2f3742d214023cfca323355f77fda9f5f58430af4b483f4019a
@@ -21,13 +21,16 @@ module Depth
21
21
  end
22
22
 
23
23
  def next(key_or_index)
24
+ return Traverser.new(
25
+ nil,
26
+ key_transformer: key_transformer,
27
+ next_proc: next_proc,
28
+ creation_proc: creation_proc
29
+ ) if object.nil?
30
+
24
31
  original_key = key_or_index
25
32
  key_or_index = key_transformer.call(object, key_or_index)
26
- next_object = if object.nil?
27
- nil
28
- else
29
- next_proc.call(object, key_or_index, original_key)
30
- end
33
+ next_object = next_proc.call(object, key_or_index, original_key)
31
34
 
32
35
  Traverser.new(
33
36
  next_object,
@@ -38,14 +41,15 @@ module Depth
38
41
  end
39
42
 
40
43
  def next_or_create(key_or_index, &block)
41
- original_key = key_or_index
42
- key_or_index = key_transformer.call(object, key_or_index)
43
44
  return Traverser.new(
44
45
  nil,
45
46
  key_transformer: key_transformer,
46
47
  next_proc: next_proc,
47
48
  creation_proc: creation_proc
48
49
  ) if object.nil?
50
+
51
+ original_key = key_or_index
52
+ key_or_index = key_transformer.call(object, key_or_index)
49
53
  next_object = next_proc.call(object, key_or_index, original_key)
50
54
  creation_proc.call(object, key_or_index, block.call, original_key) if next_object.nil?
51
55
  Traverser.new(
@@ -1,3 +1,3 @@
1
1
  module Depth
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: depth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max