Class: Plumb::MetadataVisitor

Inherits:
Object
  • Object
show all
Includes:
VisitorHandlers
Defined in:
lib/plumb/metadata_visitor.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from VisitorHandlers

included, #visit, #visit_children, #visit_name

Class Method Details

.call(node) ⇒ Object



9
10
11
# File 'lib/plumb/metadata_visitor.rb', line 9

def self.call(node)
  new.visit(node)
end

Instance Method Details

#on_missing_handler(node, props, _method_name) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/plumb/metadata_visitor.rb', line 13

def on_missing_handler(node, props, _method_name)
  return props.merge(type: node) if node.instance_of?(Class)

  return props unless node.respond_to?(:children)

  node.children.reduce(props) do |acc, child|
    visit(child, acc)
  end
end