lib/rordash/hash_util.rb in rordash-0.1.1 vs lib/rordash/hash_util.rb in rordash-0.1.2
- old
+ new
@@ -125,10 +125,10 @@
def deep_compact(attrs, each_value_proc: nil)
result = {}
dot(attrs, keep_arrays: true) do |k, v|
- value = each_value_proc.respond_to?(:call) ? each_value_proc&.call(k, v) : v.compact
+ value = each_value_proc.respond_to?(:call) ? each_value_proc&.call(k, v) : v.try(:compact)
next if value.nil?
set(result, k, value)
end