rails/rails — pull request #4748 by alexeymuranov (2012-01-29 21:52:22+00:00)
Title: Add Hash#deep_filter and Hash#deep_remove methods

Here are `Hash#deep_filter`, `#deep_filter!`, `#deep_remove`, and `#deep_remove!` methods for filtering deep hashes. This can be useful, for example, to filter `params` in a controller (this is how i am using it).

```ruby
h = { :a => 1, :b => { :c => 2, :d => 3 } }
kh = { :b => { :c => true } }
h.deep_filter(kh)
# => { :b => { :c => 2} }
h.deep_remove(kh)
# => { :a => 1, :b => { :d => 3} }
```