File tree Expand file tree Collapse file tree 4 files changed +15
-7
lines changed
Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 22 remote: .
33 specs:
44 grape (0.1.5 )
5+ hashie (~> 1.0 )
56 multi_json
67 multi_xml
78 rack
1920 guard (>= 0.2.2 )
2021 guard-rspec (0.4.2 )
2122 guard (>= 0.4.0 )
23+ hashie (1.1.0 )
2224 json_pure (1.5.2 )
2325 maruku (0.6.0 )
2426 syntax (>= 1.0.0 )
2527 multi_json (1.0.3 )
26- multi_xml (0.2.2 )
28+ multi_xml (0.3.0 )
2729 rack (1.3.0 )
2830 rack-jsonp (1.2.0 )
2931 rack
30- rack-mount (0.8.1 )
32+ rack-mount (0.8.3 )
3133 rack (>= 1.0.0 )
3234 rack-test (0.6.0 )
3335 rack (>= 1.0 )
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ Gem::Specification.new do |s|
1818 s . add_runtime_dependency 'rack-jsonp'
1919 s . add_runtime_dependency 'multi_json'
2020 s . add_runtime_dependency 'multi_xml'
21+ s . add_runtime_dependency 'hashie' , '~> 1.0'
2122
2223 s . add_development_dependency 'rake'
2324 s . add_development_dependency 'maruku'
Original file line number Diff line number Diff line change 11require 'rack'
22require 'grape'
3+ require 'hashie'
34
45module Grape
56 # An Endpoint is the proxy scope in which all routing
@@ -29,11 +30,7 @@ def self.call(env)
2930 # The parameters passed into the request as
3031 # well as parsed from URL segments.
3132 def params
32- @params ||= request . params . merge ( env [ 'rack.routing_args' ] || { } ) . inject ( { } ) do |h , ( k , v ) |
33- h [ k . to_s ] = v
34- h [ k . to_sym ] = v
35- h
36- end
33+ @params ||= Hashie ::Mash . new . deep_merge ( request . params ) . deep_merge ( env [ 'rack.routing_args' ] || { } )
3734 end
3835
3936 # The API version as specified in the URL.
Original file line number Diff line number Diff line change @@ -48,6 +48,14 @@ def app; subject end
4848 get '/hey/12'
4949 last_response . body . should == '12'
5050 end
51+
52+ it 'should deeply convert nested params' do
53+ subject . get '/location' do
54+ params [ :location ] [ :city ]
55+ end
56+ get '/location?location[city]=Dallas'
57+ last_response . body . should == 'Dallas'
58+ end
5159 end
5260
5361 describe '#error!' do
You can’t perform that action at this time.
0 commit comments