Class: Mutant::AST::FindMetaclassContaining Private
- Inherits:
-
Object
- Object
- Mutant::AST::FindMetaclassContaining
- Includes:
- NodePredicates, Procto
- Defined in:
- lib/mutant/ast/find_metaclass_containing.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Given an AST, finds the sclass that directly(-ish) contains the provided node. This won’t match arbitrarily complex structures - it only searches the first level deep (no begins-in-begins, for example). This is in keeping with mutant generally not supporting ‘weird’ syntax. Descending into ‘begin’ nodes is supported because these are generated for the one-line syntax class << self; def foo; end
Constant Summary collapse
- SCLASS_BODY_INDEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
1
Instance Method Summary collapse
-
#call ⇒ Parser::AST::Node?
private
Find metaclass node containing target node.
Methods included from Procto
Instance Method Details
#call ⇒ Parser::AST::Node?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Find metaclass node containing target node
24 25 26 27 28 29 30 |
# File 'lib/mutant/ast/find_metaclass_containing.rb', line 24 def call Structure.for(ast.node.type).each_node(ast.node) do |current| return current if n_sclass?(current) && (current) end nil end |