Class: GraphQL::Language::Visitor::NodeVisitor

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/language/visitor.rb

Overview

Collect enter and leave hooks for classes in Nodes

Access NodeVisitors via #[]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNodeVisitor

Returns a new instance of NodeVisitor.



337
338
339
340
# File 'lib/graphql/language/visitor.rb', line 337

def initialize
  @enter = []
  @leave = []
end

Instance Attribute Details

#enterArray<Proc> (readonly)

Returns Hooks to call when entering a node of this type.

Returns:

  • (Array<Proc>)

    Hooks to call when entering a node of this type



333
334
335
# File 'lib/graphql/language/visitor.rb', line 333

def enter
  @enter
end

#leaveArray<Proc> (readonly)

Returns Hooks to call when leaving a node of this type.

Returns:

  • (Array<Proc>)

    Hooks to call when leaving a node of this type



335
336
337
# File 'lib/graphql/language/visitor.rb', line 335

def leave
  @leave
end

Instance Method Details

#<<(hook) ⇒ Object

Shorthand to add a hook to the #enter array

Parameters:

  • hook (Proc)

    A hook to add



344
345
346
# File 'lib/graphql/language/visitor.rb', line 344

def <<(hook)
  enter << hook
end