lib/hm.rb
# Performs specified transformations on values of input sequence, limited only by specified
# pathes.
#
# If no `pathes` are passed, all "terminal" values (e.g. not diggable) are yielded and transformed.
#
# @example
#   order = {items: [{title: "Beef", price: 18.0}, {title: "Potato", price: 8.2}], total: 26.2}
#   Hm(order).transform_values(%i[items * price], :total, &:to_s).to_h
#   # => {:items=>[{:title=>"Beef", :price=>"18.0"}, {:title=>"Potato", :price=>"8.2"}], :total=>"26.2"}
#   Hm(order).transform_values(&:to_s).to_h
#   # => {:items=>[{:title=>"Beef", :price=>"18.0"}, {:title=>"Potato", :price=>"8.2"}], :total=>"26.2"}
#
# @see #transform_keys
# @see #transform
# @param pathes [Array] List of pathes (each being singular key, or array of keys, including
#   `:*` wildcard) to look at.
# @yieldparam value [Array] Current value to process.
# @return [self]
Performs specified transformations on values of input sequence, limited only by specified
pathes.

If no `pathes` are passed, all "terminal" values  are yielded and transformed.
Performs specified transformations on values of input sequence limited only by specified pathes . If no ` pathes ` are passed all " terminal " values are yielded and transformed .
def transform_values(*pathes)
    if pathes.empty?
      Algo.visit_all(@hash) do |at, pth, val|
        at[pth.last] = yield(val) unless Dig.diggable?(val)
      end
    else
      pathes.each do |path|
        Algo.visit(@hash, path) { |at, pth, val| at[pth.last] = yield(val) }
      end
    end
    self
  end
def transform_values ( * pathes ) if pathes . empty? Algo . visit_all ( @hash ) do | at , pth , val | at [ pth . last ] = yield ( val ) unless Dig . diggable? ( val ) end else pathes . each do | path | Algo . visit ( @hash , path ) { | at , pth , val | at [ pth . last ] = yield ( val ) } end end self end
Performs specified transformations on values of input sequence, limited only by specified
pathes.
Performs specified transformations on values of input sequence limited only by specified pathes .
None
self
pathes
List of pathes (each being singular key, or array of keys, including `:*` wildcard) to look at.
List of pathes ( each being singular key or array of keys including ` : * ` wildcard ) to look at .
value
Current value to process.
Current value to process .
example
None
see
None
see
None