lib/timber/util/hash.rb in timber-1.1.4 vs lib/timber/util/hash.rb in timber-1.1.5
- old
+ new
@@ -2,13 +2,25 @@
module Util
# @private
module Hash
extend self
- def compact(hash)
- hash.select do |k, v|
- v != nil && v != {} && v != []
+ def deep_compact(hash)
+ new_hash = {}
+
+ hash.each do |k, v|
+ v = if v.is_a?(::Hash)
+ deep_compact(v)
+ else
+ v
+ end
+
+ if v != nil && v != "" && v != {} && v != []
+ new_hash[k] = v
+ end
end
+
+ new_hash
end
end
end
end
\ No newline at end of file