class Sinatra::Base
def process_route(pattern, keys, conditions)
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) @original_params ||= @params route = @request.route route = '/' if route.empty? and not settings.empty_path_info? if match = pattern.match(route) values = match.captures.to_a 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 { |cond| throw :pass if instance_eval(&cond) == false } yield end end ensure @params = @original_params end