module Roda::RodaPlugins::BacktrackingArray::RequestMethods

def _match_array(arg, rest)

entry in the array.
matched, reset the state and continue to the next
elements. If the remaining elements could not be
array element match, attempt to match all remaining
When matching for a single array, after a successful
def _match_array(arg, rest)
  path = @remaining_path
  captures = @captures
  caps = captures.dup
  arg.each do |v|
    if match(v, rest)
      if v.is_a?(String)
        captures.push(v)
      end
      if match_all(rest)
        return true
      end
      # Matching all remaining elements failed, reset state
      captures.replace(caps)
      @remaining_path = path
    end
  end
  false
end

def match(v, rest = nil)

otherwise, just match the single argument.
When matching an array, include the remaining arguments,
def match(v, rest = nil)
  if v.is_a?(Array)
    _match_array(v, rest)
  else
    super(v)
  end
end

def match_all(args)

matcher and proceed to the next entry in the array.
that if a later matcher fails, we roll back to the current
If any of the args are an array, handle backtracking such
def match_all(args)
  args = args.dup
  until args.empty?
    arg = args.shift
    if match(arg, args)
      return true if arg.is_a?(Array)
    else
      return
    end
  end
  true
end