module RuboCop::AST::NodePattern::MethodDefiner

def emit_yield_capture(when_no_capture = '', yield_with: 'yield')

def emit_yield_capture(when_no_capture = '', yield_with: 'yield')
  yield_val = if captures.zero?
                when_no_capture
              elsif captures == 1
                'captures[0]' # Circumvent https://github.com/jruby/jruby/issues/5710
              else
                '*captures'
              end
  "#{yield_with}(#{yield_val})"
end