lib/active_object/hash.rb in active_object-4.0.9 vs lib/active_object/hash.rb in active_object-4.0.10
- old
+ new
@@ -62,9 +62,17 @@
self
end
# rubocop:enable Metrics/MethodLength
+ def denillify(value = 0)
+ each { |key, val| self[key] = val.nil? ? value : val }
+ end
+
+ def denillify!(value = 0)
+ replace(denillify(value))
+ end
+
def dig(key, *rest)
value = (self[key] rescue nil)
return if value.nil?
return value if rest.empty?