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.
567 568 569 570 571 572 573 574 |
# File 'lib/graphql/upgrader/member.rb', line 567 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.
566 567 568 |
# File 'lib/graphql/upgrader/member.rb', line 566 def proc_arg_names @proc_arg_names end |
#proc_end ⇒ Object (readonly)
Returns the value of attribute proc_end.
566 567 568 |
# File 'lib/graphql/upgrader/member.rb', line 566 def proc_end @proc_end end |
#proc_start ⇒ Object (readonly)
Returns the value of attribute proc_start.
566 567 568 |
# File 'lib/graphql/upgrader/member.rb', line 566 def proc_start @proc_start end |
#resolve_end ⇒ Object (readonly)
Returns the value of attribute resolve_end.
566 567 568 |
# File 'lib/graphql/upgrader/member.rb', line 566 def resolve_end @resolve_end end |
#resolve_indent ⇒ Object (readonly)
Returns the value of attribute resolve_indent.
566 567 568 |
# File 'lib/graphql/upgrader/member.rb', line 566 def resolve_indent @resolve_indent end |
#resolve_start ⇒ Object (readonly)
Returns the value of attribute resolve_start.
566 567 568 |
# File 'lib/graphql/upgrader/member.rb', line 566 def resolve_start @resolve_start end |
Instance Method Details
#on_block(node) ⇒ Object
587 588 589 590 591 592 593 594 595 596 597 598 |
# File 'lib/graphql/upgrader/member.rb', line 587 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
576 577 578 579 580 581 582 583 584 585 |
# File 'lib/graphql/upgrader/member.rb', line 576 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 |