Class: GraphQL::Upgrader::ResolveProcToMethodTransform::ResolveProcProcessor
- Inherits:
-
Parser::AST::Processor
- Object
- Parser::AST::Processor
- GraphQL::Upgrader::ResolveProcToMethodTransform::ResolveProcProcessor
- Defined in:
- lib/graphql/upgrader/member.rb
Instance Attribute Summary collapse
-
#proc_arg_names ⇒ Object
readonly
Returns the value of attribute proc_arg_names.
-
#proc_end ⇒ Object
readonly
Returns the value of attribute proc_end.
-
#proc_start ⇒ Object
readonly
Returns the value of attribute proc_start.
-
#resolve_end ⇒ Object
readonly
Returns the value of attribute resolve_end.
-
#resolve_indent ⇒ Object
readonly
Returns the value of attribute resolve_indent.
-
#resolve_start ⇒ Object
readonly
Returns the value of attribute resolve_start.
Instance Method Summary collapse
-
#initialize ⇒ ResolveProcProcessor
constructor
A new instance of ResolveProcProcessor.
-
#on_block(node) ⇒ Object
-
#on_send(node) ⇒ Object
Constructor Details
#initialize ⇒ ResolveProcProcessor
Returns a new instance of ResolveProcProcessor
563 564 565 566 567 568 569 570 |
# File 'lib/graphql/upgrader/member.rb', line 563 def initialize @proc_arg_names = nil @resolve_start = nil @resolve_end = nil @resolve_indent = nil @proc_start = nil @proc_end = nil end |
Instance Attribute Details
#proc_arg_names ⇒ Object (readonly)
Returns the value of attribute proc_arg_names
562 563 564 |
# File 'lib/graphql/upgrader/member.rb', line 562 def proc_arg_names @proc_arg_names end |
#proc_end ⇒ Object (readonly)
Returns the value of attribute proc_end
562 563 564 |
# File 'lib/graphql/upgrader/member.rb', line 562 def proc_end @proc_end end |
#proc_start ⇒ Object (readonly)
Returns the value of attribute proc_start
562 563 564 |
# File 'lib/graphql/upgrader/member.rb', line 562 def proc_start @proc_start end |
#resolve_end ⇒ Object (readonly)
Returns the value of attribute resolve_end
562 563 564 |
# File 'lib/graphql/upgrader/member.rb', line 562 def resolve_end @resolve_end end |
#resolve_indent ⇒ Object (readonly)
Returns the value of attribute resolve_indent
562 563 564 |
# File 'lib/graphql/upgrader/member.rb', line 562 def resolve_indent @resolve_indent end |
#resolve_start ⇒ Object (readonly)
Returns the value of attribute resolve_start
562 563 564 |
# File 'lib/graphql/upgrader/member.rb', line 562 def resolve_start @resolve_start end |
Instance Method Details
#on_block(node) ⇒ Object
583 584 585 586 587 588 589 590 591 592 593 594 |
# File 'lib/graphql/upgrader/member.rb', line 583 def on_block(node) send_node, args_node, body_node = node.children _receiver, method_name, _send_args_node = *send_node # Assume that the first three-argument proc we enter is the resolve if method_name == :lambda && args_node.children.size == 3 && @proc_arg_names.nil? source_exp = body_node.loc.expression @proc_arg_names = args_node.children.map { |arg_node| arg_node.children[0].to_s } @proc_start = source_exp.begin.begin_pos @proc_end = source_exp.end.end_pos end super(node) end |
#on_send(node) ⇒ Object
572 573 574 575 576 577 578 579 580 581 |
# File 'lib/graphql/upgrader/member.rb', line 572 def on_send(node) receiver, method_name, _args = *node if method_name == :resolve && receiver.nil? source_exp = node.loc.expression @resolve_start = source_exp.begin.begin_pos @resolve_end = source_exp.end.end_pos @resolve_indent = source_exp.column end super(node) end |