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 +4 -4
- data/lib/depth/traverser.rb +11 -7
- data/lib/depth/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2d275d97521a90922bfd87e95208fcb99cbf836
|
4
|
+
data.tar.gz: d31499f6313426697c37222541c3559b91e9cc18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 524e6b44d60c2fc130f83b81eb6b200b735692ab3c6b0a05ce0f908fd30047b038c5b3623f280e8b42d64ffaa59bb25a96e197c8fc6509895e3ee5f6bf5966a7
|
7
|
+
data.tar.gz: 12e3c45354a6d046a40496e0a01f4ea2fdb8be0b24f5ae0b18b3d1a13cd4eb25dbbad1d1465ef2f3742d214023cfca323355f77fda9f5f58430af4b483f4019a
|
data/lib/depth/traverser.rb
CHANGED
@@ -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 =
|
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(
|
data/lib/depth/version.rb
CHANGED