Module: Gemmy::Patches::HashPatch::InstanceMethods::RecursiveKeys
- Defined in:
- lib/gemmy/patches/hash_patch.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#recursive_keys ⇒ Object
returns an array of arrays.
Class Method Details
.recursive_keys(hash) ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/gemmy/patches/hash_patch.rb', line 82 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 |
Instance Method Details
#recursive_keys ⇒ Object
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.
79 80 81 |
# File 'lib/gemmy/patches/hash_patch.rb', line 79 def recursive_keys Gemmy.patch("hash/i/recursive_keys").recursive_keys self end |