hashlib 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/hashlib.rb +19 -9
- metadata +1 -1
data/lib/hashlib.rb
CHANGED
@@ -129,23 +129,33 @@ class Hash
|
|
129
129
|
rv
|
130
130
|
end
|
131
131
|
|
132
|
-
def each_recurse(
|
133
|
-
root
|
134
|
-
|
132
|
+
def each_recurse(options={}, &block)
|
133
|
+
options[:root] = self if options[:root].nil?
|
134
|
+
options[:path] = [] if options[:path].nil?
|
135
|
+
|
136
|
+
options[:root].each do |k,v|
|
137
|
+
options[:path] << k
|
135
138
|
|
136
139
|
if v.is_a?(Hash)
|
137
|
-
|
140
|
+
yield(k, v, options[:path]) if options[:intermediate] === true
|
141
|
+
|
142
|
+
each_recurse(options.merge({
|
143
|
+
:root => v,
|
144
|
+
:path => options[:path]
|
145
|
+
}), &block)
|
138
146
|
else
|
139
|
-
rv = yield(k, v, path)
|
140
|
-
self.set(path, rv) if inplace === true
|
147
|
+
rv = yield(k, v, options[:path])
|
148
|
+
self.set(options[:path], rv) if options[:inplace] === true
|
141
149
|
end
|
142
150
|
|
143
|
-
path.pop
|
151
|
+
options[:path].pop
|
144
152
|
end
|
145
153
|
end
|
146
154
|
|
147
|
-
def each_recurse!(
|
148
|
-
each_recurse(
|
155
|
+
def each_recurse!(options={}, &block)
|
156
|
+
each_recurse(options.merge({
|
157
|
+
:inplace => true
|
158
|
+
}), &block)
|
149
159
|
end
|
150
160
|
|
151
161
|
def compact
|