Slice a nested hash

Updated . Posted . Visible to the public.

The attached initializer gives your hashes a #deep_slice method that lets you recursively slice Show archive.org snapshot their contents by a given whitelist of allowed keys and sub-keys:

{ :a => { :b => 'b', :c => 'c' } }.deep_slice(:a => :c) # => { :a => { :c => 'c' } }
Henning Koch
Last edit
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2012-08-13 14:13)