1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

Symbol params back in thanks to Jeremy Evans

This commit is contained in:
Blake Mizerany 2008-04-08 16:40:21 -07:00
parent 74bfd99011
commit 98572b4d0d
2 changed files with 24 additions and 2 deletions

View file

@ -587,9 +587,12 @@ module Sinatra
end
def params
@params = @route_params.merge(@request.params)
@params ||= begin
h = Hash.new {|h,k| h[k.to_s] if Symbol === k}
h.merge(@route_params.merge(@request.params))
end
end
def stop(*args)
throw :halt, args
end

19
test/sym_params_test.rb Normal file
View file

@ -0,0 +1,19 @@
require File.dirname(__FILE__) + '/helper'
context "Symbol Params" do
setup do
Sinatra.application = nil
end
specify "should be accessable as Strings or Symbols" do
get '/' do
params[:foo] + params['foo']
end
get_it '/', :foo => "X"
assert_equal('XX', body)
end
end