class Sinatra::Base
def process_route(pattern, keys, conditions, block = nil, values = [])
Revert params afterwards.
with keys and call the given block.
If the current request matches pattern and conditions, fill params
def process_route(pattern, keys, conditions, block = nil, values = []) @original_params ||= @params route = @request.path_info route = '/' if route.empty? and not settings.empty_path_info? if match = pattern.match(route) values += match.captures.to_a.map { |v| force_encoding URI.decode(v) if v } params = if keys.any? keys.zip(values).inject({}) do |hash,(k,v)| if k == 'splat' (hash[k] ||= []) << v else hash[k] = v end hash end elsif values.any? {'captures' => values} else {} end @params = @original_params.merge(params) @block_params = values catch(:pass) do conditions.each { |c| throw :pass if c.bind(self).call == false } block ? block[self, @block_params] : yield(self, @block_params) end end ensure @params = @original_params end