Class: GraphQL::Language::Visitor
- Inherits:
-
Object
- Object
- GraphQL::Language::Visitor
- Defined in:
- lib/graphql/language/visitor.rb
Overview
Depth-first traversal through the tree, calling hooks at each stop.
Defined Under Namespace
Classes: NodeVisitor
Constant Summary
- SKIP =
If any hook returns this value, the GraphQL::Language::Visitor stops visiting this node right away
:_skip
Instance Method Summary collapse
-
#[](node_class) ⇒ NodeVisitor
Get a NodeVisitor for
node_class
. -
#initialize(document) ⇒ Visitor
constructor
A new instance of Visitor.
-
#visit ⇒ void
Visit
document
and all children, applying hooks as you go.
Constructor Details
#initialize(document) ⇒ Visitor
Returns a new instance of Visitor
21 22 23 24 |
# File 'lib/graphql/language/visitor.rb', line 21 def initialize(document) @document = document @visitors = {} end |
Instance Method Details
#[](node_class) ⇒ NodeVisitor
Get a NodeVisitor for node_class
32 33 34 |
# File 'lib/graphql/language/visitor.rb', line 32 def [](node_class) @visitors[node_class] ||= NodeVisitor.new end |
#visit ⇒ void
This method returns an undefined value.
Visit document
and all children, applying hooks as you go
38 39 40 |
# File 'lib/graphql/language/visitor.rb', line 38 def visit visit_node(@document, nil) end |