module Roda::RodaPlugins::OptimizedMatching::RequestMethods
def _is1(args, &block)
Internals of r.is/r.get/r.post optimization. Inline the related matching
def _is1(args, &block) case matcher = args[0] when String rp = @remaining_path if _match_string(matcher) if @remaining_path.empty? always{yield} else @remaining_path = rp nil end end when Class if matcher == String rp = @remaining_path if rp.getbyte(0) == 47 && !rp.index('/', 1) && (len = rp.length) > 1 @remaining_path = '' always{yield rp[1, len]} end elsif matcher == Integer if (matchdata = /\A\/(\d{1,100})\z/.match(@remaining_path)) && (value = _match_class_convert_Integer(matchdata[1])) @remaining_path = '' always{yield(value)} end else path = @remaining_path captures = @captures.clear meth = :"_match_class_#{matcher}" if respond_to?(meth, true) # Allow calling private methods, as match methods are generally private if send(meth, &block) && @remaining_path.empty? block_result(yield(*captures)) throw :halt, response.finish else @remaining_path = path false end else unsupported_matcher(matcher) end end when Regexp if (matchdata = self.class.cached_matcher(matcher){matcher}.match(@remaining_path)) && matchdata.post_match.empty? @remaining_path = '' always{yield(*matchdata.captures)} end when true always(&block) if @remaining_path.empty? when false, nil # nothing else path = @remaining_path captures = @captures.clear matched = case matcher when Array _match_array(matcher) when Hash _match_hash(matcher) when Symbol _match_symbol(matcher) when Proc matcher.call else unsupported_matcher(matcher) end if matched && @remaining_path.empty? block_result(yield(*captures)) throw :halt, response.finish else @remaining_path = path false end end end