lib/refinements/hash.rb in refinements-12.8.0 vs lib/refinements/hash.rb in refinements-12.9.0
- old
+ new
@@ -78,12 +78,18 @@
def symbolize_keys = transform_keys(&:to_sym)
def symbolize_keys! = transform_keys!(&:to_sym)
- def transform_with(operations) = dup.transform_with! operations
+ def transform_value(key, &) = dup.transform_value!(key, &)
- def transform_with! operations
+ def transform_value! key
+ block_given? && key?(key) ? merge!(key => yield(self[key])) : self
+ end
+
+ def transform_with(**) = dup.transform_with!(**)
+
+ def transform_with!(**operations)
operations.each { |key, function| self[key] = function.call self[key] if key? key }
self
end
def use &block