Class: PrettyApi::Utils::Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/pretty_api/utils/hash.rb

Class Method Summary collapse

Class Method Details

.deep_compact_blank(hash) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/pretty_api/utils/hash.rb', line 4

def self.deep_compact_blank(hash)
  hash.each_with_object({}) do |(k, v), new_hash|
    v = deep_compact_blank(v) if v.is_a? ::Hash
    v = v.compact_blank if v.is_a? ::Array
    new_hash[k] = v if v.present?
  end
end