Method: BBLib::HashPathProc#process

Defined in:
lib/hash_path/proc.rb

#process(hash) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/hash_path/proc.rb', line 18

def process(hash)
  return hash unless @action && hash
  tree = hash.to_tree_hash
  paths.each do |path|
    children = recursive ? tree.find(path).flat_map(&:descendants) : tree.find(path)
    children.each do |child|
      next unless check_condition(child.value)
      HashPathProcs.send(find_action(action), child, *full_args, class_based: class_based)
    end
  end
  hash.replace(tree.value) rescue tree.value
end