Sha256: ef51015617ddd764510cea156811c8289f23eca7e12daafad90125f53ee234f0

Contents?: true

Size: 276 Bytes

Versions: 18

Compression:

Stored size: 276 Bytes

Contents

module HashExt
  module Traverse
    def self.traverse(hash, &block)
      hash.inject({}) do |h,(k,v)|
        if Hash === v
          v = traverse(v,&block)
        end
        nk, nv = block.call(k,v)
        h[nk] = nv unless nk.nil?
        h
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
coprl-3.0.0.beta.12 lib/hash_ext/traverse.rb
coprl-3.0.0.beta.11 lib/hash_ext/traverse.rb
coprl-3.0.0.beta.10 lib/hash_ext/traverse.rb
coprl-3.0.0.beta.9 lib/hash_ext/traverse.rb
coprl-3.0.0.beta.8 lib/hash_ext/traverse.rb
coprl-3.0.0.beta.7 lib/hash_ext/traverse.rb
coprl-3.0.0.beta.6 lib/hash_ext/traverse.rb
coprl-3.0.0.beta.5 lib/hash_ext/traverse.rb
voom-presenters-2.1.2 lib/hash_ext/traverse.rb
coprl-3.0.0.beta.4 lib/hash_ext/traverse.rb
coprl-3.0.0.beta.3 lib/hash_ext/traverse.rb
coprl-3.0.0.beta.2 lib/hash_ext/traverse.rb
coprl-3.0.0.beta.1 lib/hash_ext/traverse.rb
voom-presenters-2.1.0 lib/hash_ext/traverse.rb
voom-presenters-2.0.3 lib/hash_ext/traverse.rb
voom-presenters-2.0.2 lib/hash_ext/traverse.rb
voom-presenters-2.0.1 lib/hash_ext/traverse.rb
voom-presenters-2.0.0 lib/hash_ext/traverse.rb