Module: GlueGun::HashExtensions
- Defined in:
- lib/glue_gun/core_ext/hash_extensions.rb
Instance Method Summary collapse
Instance Method Details
#deep_compact ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/glue_gun/core_ext/hash_extensions.rb', line 3 def deep_compact each_with_object({}) do |(key, value), result| next if value.nil? compacted = if value.is_a?(Hash) value.deep_compact elsif value.is_a?(Array) value.map { |v| v.is_a?(Hash) ? v.deep_compact : v }.compact else value end result[key] = compacted unless compacted.is_a?(String) && compacted.blank? end end |