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 collapse
- 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.
20 21 22 23 |
# File 'lib/graphql/language/visitor.rb', line 20 def initialize(document) @document = document @visitors = {} end |
Instance Method Details
#[](node_class) ⇒ NodeVisitor
Get a NodeVisitor for node_class
31 32 33 |
# File 'lib/graphql/language/visitor.rb', line 31 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
37 38 39 |
# File 'lib/graphql/language/visitor.rb', line 37 def visit visit_node(@document, nil) end |