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.
Files changed (2) hide show
  1. data/lib/hashlib.rb +19 -9
  2. 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(root=self, path=[], inplace=false, &block)
133
- root.each do |k,v|
134
- path << k
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
- each_recurse(v, path, inplace, &block)
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!(root=self, path=[], &block)
148
- each_recurse(root, path, true, &block)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.21
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: