Class: ActiverecordCallbackLens::Parser::ConditionParser::LambdaLocator

Inherits:
Prism::Visitor
  • Object
show all
Defined in:
lib/activerecord_callback_lens/parser/condition_parser.rb

Overview

A Prism visitor that captures the innermost LambdaNode or BlockNode whose source range encloses a target line. Used to isolate a single proc's body from the surrounding file AST.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target_line:) ⇒ LambdaLocator

Returns a new instance of LambdaLocator.

Parameters:

  • the line the proc's source_location reports



109
110
111
112
113
# File 'lib/activerecord_callback_lens/parser/condition_parser.rb', line 109

def initialize(target_line:)
  @target_line = target_line
  @node = nil
  super()
end

Instance Attribute Details

#nodePrism::Node? (readonly)

Returns the body of the innermost matching lambda/block.

Returns:

  • the body of the innermost matching lambda/block



106
107
108
# File 'lib/activerecord_callback_lens/parser/condition_parser.rb', line 106

def node
  @node
end

Instance Method Details

#visit_block_node(block_node) ⇒ void

This method returns an undefined value.

Parameters:



124
125
126
127
# File 'lib/activerecord_callback_lens/parser/condition_parser.rb', line 124

def visit_block_node(block_node)
  capture(block_node)
  super
end

#visit_lambda_node(lambda_node) ⇒ void

This method returns an undefined value.

Parameters:



117
118
119
120
# File 'lib/activerecord_callback_lens/parser/condition_parser.rb', line 117

def visit_lambda_node(lambda_node)
  capture(lambda_node)
  super
end