Skip to content

Instantly share code, notes, and snippets.

@jodell
Created January 24, 2013 16:40
Show Gist options
  • Save jodell/4624772 to your computer and use it in GitHub Desktop.
Save jodell/4624772 to your computer and use it in GitHub Desktop.
module RecursiveHashExtensions
def rmap(&blk)
self.reduce({}) do |acc, (k, v)|
acc[k] = v.is_a?(Hash) ? v.rmap(&blk) : blk.call(k, v)
end
end
end
class Hash
include RecursiveHashExtensions
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment