Class: ActionDispatch::Request::Utils

Inherits:
Object
  • Object
show all
Defined in:
actionpack/lib/action_dispatch/request/utils.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.deep_munge(hash) ⇒ Object

Remove nils from the params hash



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'actionpack/lib/action_dispatch/request/utils.rb', line 6

def deep_munge(hash)
  hash.each do |k, v|
    case v
    when Array
      v.grep(Hash) { |x| deep_munge(x) }
      v.compact!
      hash[k] = nil if v.empty?
    when Hash
      deep_munge(v)
    end
  end

  hash
end