Method: RuboCop::AST::NodePattern::Macros#def_node_matcher
- Defined in:
- lib/rubocop/ast/node_pattern.rb
#def_node_matcher(method_name, pattern_str, **keyword_defaults) ⇒ Object
Define a method which applies a pattern to an AST node
The new method will return nil if the node does not match. If the node matches, and a block is provided, the new method will yield to the block (passing any captures as block arguments). If the node matches, and no block is provided, the new method will return the captures, or ‘true` if there were none.
36 37 38 |
# File 'lib/rubocop/ast/node_pattern.rb', line 36 def def_node_matcher(method_name, pattern_str, **keyword_defaults) NodePattern.new(pattern_str).def_node_matcher(self, method_name, **keyword_defaults) end |