hashlib 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hashlib.rb +6 -2
- metadata +1 -1
data/lib/hashlib.rb
CHANGED
@@ -98,7 +98,7 @@ class Hash
|
|
98
98
|
rv
|
99
99
|
end
|
100
100
|
|
101
|
-
def each_recurse(root=self, path=[], &block)
|
101
|
+
def each_recurse(root=self, path=[], inplace=false, &block)
|
102
102
|
root.each do |k,v|
|
103
103
|
path << k
|
104
104
|
|
@@ -106,13 +106,17 @@ class Hash
|
|
106
106
|
each_recurse(v, path, &block)
|
107
107
|
else
|
108
108
|
rv = yield(k, v, path)
|
109
|
-
root[k] = rv
|
109
|
+
root[k] = rv if inplace === true
|
110
110
|
end
|
111
111
|
|
112
112
|
path.pop
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
|
+
def each_recurse!(root=self, path=[], &block)
|
117
|
+
each_recurse(root, path, true, &block)
|
118
|
+
end
|
119
|
+
|
116
120
|
def compact
|
117
121
|
def _is_empty?(i)
|
118
122
|
i === nil or (i.is_a?(String) and i.strip.chomp.empty?) or (i.respond_to?(:empty?) and i.empty?)
|