hashlib 0.0.31 → 0.0.32
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hashlib.rb +15 -3
- metadata +1 -1
data/lib/hashlib.rb
CHANGED
@@ -34,20 +34,32 @@ class Hash
|
|
34
34
|
if root.has_key?(key)
|
35
35
|
if root[key].is_a?(Hash)
|
36
36
|
if rest.empty?
|
37
|
-
|
37
|
+
if root[key].nil?
|
38
|
+
return default
|
39
|
+
else
|
40
|
+
return root[key]
|
41
|
+
end
|
38
42
|
else
|
39
43
|
return root[key].rget(rest, default)
|
40
44
|
end
|
41
45
|
elsif root[key].is_a?(Array) and root[key].first.is_a?(Hash)
|
42
46
|
if rest.empty?
|
43
|
-
|
47
|
+
if root[key].nil?
|
48
|
+
return default
|
49
|
+
else
|
50
|
+
return root[key]
|
51
|
+
end
|
44
52
|
else
|
45
53
|
return root[key].collect{|v|
|
46
54
|
v.rget(rest, default)
|
47
55
|
}.flatten
|
48
56
|
end
|
49
57
|
else
|
50
|
-
|
58
|
+
if root[key].nil?
|
59
|
+
return default
|
60
|
+
else
|
61
|
+
return root[key]
|
62
|
+
end
|
51
63
|
end
|
52
64
|
else
|
53
65
|
return default
|