1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

PARAMETERS_KEY is only used in the request, so move the constant there

This commit is contained in:
Aaron Patterson 2014-05-27 14:46:04 -07:00
parent cfdab77d1f
commit 2ffa126f79
3 changed files with 9 additions and 9 deletions

View file

@ -4,6 +4,8 @@ require 'active_support/core_ext/hash/indifferent_access'
module ActionDispatch
module Http
module Parameters
PARAMETERS_KEY = 'action_dispatch.request.path_parameters'
def initialize(env)
super
@symbolized_path_params = nil
@ -25,7 +27,7 @@ module ActionDispatch
def path_parameters=(parameters) #:nodoc:
@env.delete('action_dispatch.request.parameters')
@env[Routing::RouteSet::PARAMETERS_KEY] = parameters
@env[PARAMETERS_KEY] = parameters
end
# The same as <tt>path_parameters</tt> with explicitly symbolized keys.
@ -40,7 +42,7 @@ module ActionDispatch
#
# See <tt>symbolized_path_parameters</tt> for symbolized keys.
def path_parameters
@env[Routing::RouteSet::PARAMETERS_KEY] ||= {}
@env[PARAMETERS_KEY] ||= {}
end
private

View file

@ -19,8 +19,6 @@ module ActionDispatch
# alias inspect to to_s.
alias inspect to_s
PARAMETERS_KEY = 'action_dispatch.request.path_parameters'
class Dispatcher < Routing::Endpoint #:nodoc:
def initialize(defaults)
@defaults = defaults

View file

@ -87,7 +87,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_symbols_with_dashes
rs.draw do
get '/:artist/:song-omg', :to => lambda { |env|
resp = ActiveSupport::JSON.encode env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]
resp = ActiveSupport::JSON.encode ActionDispatch::Request.new(env).path_parameters
[200, {}, [resp]]
}
end
@ -99,7 +99,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_id_with_dash
rs.draw do
get '/journey/:id', :to => lambda { |env|
resp = ActiveSupport::JSON.encode env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]
resp = ActiveSupport::JSON.encode ActionDispatch::Request.new(env).path_parameters
[200, {}, [resp]]
}
end
@ -111,7 +111,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_dash_with_custom_regexp
rs.draw do
get '/:artist/:song-omg', :constraints => { :song => /\d+/ }, :to => lambda { |env|
resp = ActiveSupport::JSON.encode env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]
resp = ActiveSupport::JSON.encode ActionDispatch::Request.new(env).path_parameters
[200, {}, [resp]]
}
end
@ -124,7 +124,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_pre_dash
rs.draw do
get '/:artist/omg-:song', :to => lambda { |env|
resp = ActiveSupport::JSON.encode env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]
resp = ActiveSupport::JSON.encode ActionDispatch::Request.new(env).path_parameters
[200, {}, [resp]]
}
end
@ -136,7 +136,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
def test_pre_dash_with_custom_regexp
rs.draw do
get '/:artist/omg-:song', :constraints => { :song => /\d+/ }, :to => lambda { |env|
resp = ActiveSupport::JSON.encode env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]
resp = ActiveSupport::JSON.encode ActionDispatch::Request.new(env).path_parameters
[200, {}, [resp]]
}
end