Method: RuboCop::AST::NodePattern::Macros#def_node_search

Defined in:
lib/rubocop/ast/node_pattern.rb

#def_node_search(method_name, pattern_str, **keyword_defaults) ⇒ Object

Define a method which recurses over the descendants of an AST node, checking whether any of them match the provided pattern

If the method name ends with ‘?’, the new method will return true as soon as it finds a descendant which matches. Otherwise, it will yield all descendants which match.



46
47
48
# File 'lib/rubocop/ast/node_pattern.rb', line 46

def def_node_search(method_name, pattern_str, **keyword_defaults)
  NodePattern.new(pattern_str).def_node_search(self, method_name, **keyword_defaults)
end