lib/active_object/hash.rb in active_object-5.2.3 vs lib/active_object/hash.rb in active_object-5.2.4
- old
+ new
@@ -129,9 +129,19 @@
hash = {}
keys.flatten.each { |key| hash[key] = self[key] if key?(key) }
replace(hash)
end
+ def only_fill(*keys, placeholder: nil)
+ dup.only_fill!(*keys, placeholder: placeholder)
+ end
+
+ def only_fill!(*keys, placeholder: nil)
+ hash = {}
+ keys.flatten.each { |key| hash[key] = key?(key) ? self[key] : placeholder }
+ replace(hash)
+ end
+
def pair?(key, value)
self[key] == value
end
def promote(key)