class Constancy::Util

Public Class Methods

flatten_hash(h,f=[],g={}) click to toggle source

stackoverflow.com/questions/9647997/converting-a-nested-hash-into-a-flat-hash

# File lib/constancy.rb, line 38
def flatten_hash(h,f=[],g={})
  return g.update({ f=>h }) unless h.is_a? Hash
  h.each { |k,r| flatten_hash(r,f+[k],g) }
  g
end