module Gemmy::Patches::HashPatch::InstanceMethods::RecursiveKeys

Public Class Methods

recursive_keys(hash) click to toggle source
# File lib/gemmy/patches/hash_patch.rb, line 94
def self.recursive_keys hash
  toplevel_keys = hash.keys.map &Array.method(:wrap)
  toplevel_keys.map do |key_array|
    if hash[key].is_a? Hash
      key_array.concat recursive_keys hash[key]
    else
      key_array
    end
  end
end

Public Instance Methods

recursive_keys() click to toggle source

returns an array of arrays. Each sub-array is a list of keys. This list can be passed to Hash#dig with a splat operator.

# File lib/gemmy/patches/hash_patch.rb, line 91
def recursive_keys
  Gemmy.patch("hash/i/recursive_keys").recursive_keys self
end