Class: ActiverecordCallbackLens::Resolver::MethodResolver::DefLocator
- Inherits:
-
Prism::Visitor
- Object
- Prism::Visitor
- ActiverecordCallbackLens::Resolver::MethodResolver::DefLocator
- Defined in:
- lib/activerecord_callback_lens/resolver/method_resolver.rb
Overview
A Prism visitor that captures the body of the DefNode matching a target line (and, when available, a target method name). Mirrors ConditionParser’s LambdaLocator but targets ‘def` definitions rather than lambdas/blocks.
Instance Attribute Summary collapse
-
#node ⇒ Prism::Node?
readonly
The body of the matched DefNode.
Instance Method Summary collapse
-
#initialize(target_line:, method_name: nil) ⇒ DefLocator
constructor
A new instance of DefLocator.
- #visit_def_node(def_node) ⇒ void
Constructor Details
#initialize(target_line:, method_name: nil) ⇒ DefLocator
Returns a new instance of DefLocator.
218 219 220 221 222 223 |
# File 'lib/activerecord_callback_lens/resolver/method_resolver.rb', line 218 def initialize(target_line:, method_name: nil) @target_line = target_line @method_name = method_name @node = nil super() end |
Instance Attribute Details
#node ⇒ Prism::Node? (readonly)
Returns the body of the matched DefNode.
214 215 216 |
# File 'lib/activerecord_callback_lens/resolver/method_resolver.rb', line 214 def node @node end |
Instance Method Details
#visit_def_node(def_node) ⇒ void
This method returns an undefined value.
227 228 229 230 |
# File 'lib/activerecord_callback_lens/resolver/method_resolver.rb', line 227 def visit_def_node(def_node) capture(def_node) super end |