Method: GraphQL::Language::StaticVisitor.make_visit_methods
- Defined in:
- lib/graphql/language/static_visitor.rb
.make_visit_methods(ast_node_class) ⇒ Object
We don't use alias here because it breaks super
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/graphql/language/static_visitor.rb', line 96 def self.make_visit_methods(ast_node_class) node_method = ast_node_class.visit_method children_of_type = ast_node_class.children_of_type child_visit_method = :"#{node_method}_children" class_eval(" # The default implementation for visiting an AST node.\n # It doesn't _do_ anything, but it continues to visiting the node's children.\n # To customize this hook, override one of its make_visit_methods (or the base method?)\n # in your subclasses.\n #\n # @param node [GraphQL::Language::Nodes::AbstractNode] the node being visited\n # @param parent [GraphQL::Language::Nodes::AbstractNode, nil] the previously-visited node, or `nil` if this is the root node.\n # @return [void]\n def \#{node_method}(node, parent)\n \#{\n if method_defined?(child_visit_method)\n \"\#{child_visit_method}(node)\"\n elsif children_of_type\n children_of_type.map do |child_accessor, child_class|\n \"node.\#{child_accessor}.each do |child_node|\n \#{child_class.visit_method}(child_node, node)\n end\"\n end.join(\"\\n\")\n else\n \"\"\n end\n }\n end\n RUBY\nend\n", __FILE__, __LINE__ + 1) |