Read more

Slice a nested hash

Henning Koch
August 13, 2012Software engineer at makandra GmbH

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' } }
Illustration book lover

Growing Rails Applications in Practice

Check out our e-book. Learn to structure large Ruby on Rails codebases with the tools you already know and love.

  • Introduce design conventions for controllers and user-facing models
  • Create a system for growth
  • Build applications to last
Read more Show archive.org snapshot
Posted by Henning Koch to makandra dev (2012-08-13 16:13)