Sha256: 701194f923dc5288c8cd4ac0bc855dee2f6fe0505d9e748f3a4204951ecd79aa

Contents?: true

Size: 442 Bytes

Versions: 4

Compression:

Stored size: 442 Bytes

Contents

# typed: false
# frozen_string_literal: true

module Packwerk
  class NodeVisitor
    def initialize(node_processor:)
      @node_processor = node_processor
    end

    def visit(node, ancestors:, result:)
      result.concat(@node_processor.call(node, ancestors))

      child_ancestors = [node] + ancestors
      Node.each_child(node) do |child|
        visit(child, ancestors: child_ancestors, result: result)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
packwerk-1.3.2 lib/packwerk/node_visitor.rb
packwerk-1.3.1 lib/packwerk/node_visitor.rb
packwerk-1.3.0 lib/packwerk/node_visitor.rb
packwerk-1.2.0 lib/packwerk/node_visitor.rb