aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing
diff options
context:
space:
mode:
authorwycats <wycats@gmail.com>2010-04-03 20:23:23 -0700
committerwycats <wycats@gmail.com>2010-04-03 20:24:30 -0700
commitab8bf9e152ad75c8b358c85e4c95cfde578de127 (patch)
tree1e5887a4c0bdbf0750c359dc8d1c6d2d5585a5bf /actionpack/lib/action_dispatch/routing
parent512b4bccfbe222bd7f94adf6f9af07c2e856767d (diff)
downloadrails-ab8bf9e152ad75c8b358c85e4c95cfde578de127.tar.gz
rails-ab8bf9e152ad75c8b358c85e4c95cfde578de127.tar.bz2
rails-ab8bf9e152ad75c8b358c85e4c95cfde578de127.zip
* Change the object used in routing constraints to be an instance of
ActionDispatch::Request rather than Rack::Request. * Changed ActionDispatch::Request#method to return a String, to be compatible with the Rack::Request superclass. * Changed ActionDispatch::Request#method to return the original method in the case of methodoverride and #request_method not to, to be compatible with Rack::Request
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb13
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb10
2 files changed, 14 insertions, 9 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 2c7ee7dad0..ffa178345b 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -5,20 +5,20 @@ module ActionDispatch
module Routing
class Mapper
class Constraints #:nodoc:
- def self.new(app, constraints = [])
+ def self.new(app, constraints, request = Rack::Request)
if constraints.any?
- super(app, constraints)
+ super(app, constraints, request)
else
app
end
end
- def initialize(app, constraints = [])
- @app, @constraints = app, constraints
+ def initialize(app, constraints, request)
+ @app, @constraints, @request = app, constraints, request
end
def call(env)
- req = Rack::Request.new(env)
+ req = @request.new(env)
@constraints.each { |constraint|
if constraint.respond_to?(:matches?) && !constraint.matches?(req)
@@ -83,7 +83,8 @@ module ActionDispatch
def app
Constraints.new(
to.respond_to?(:call) ? to : Routing::RouteSet::Dispatcher.new(:defaults => defaults),
- blocks
+ blocks,
+ @set.request_class
)
end
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index c8e4371bb7..f1965f38b9 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -187,18 +187,19 @@ module ActionDispatch
attr_accessor :routes, :named_routes
attr_accessor :disable_clear_and_finalize, :resources_path_names
- attr_accessor :default_url_options
+ attr_accessor :default_url_options, :request_class
def self.default_resources_path_names
{ :new => 'new', :edit => 'edit' }
end
- def initialize
+ def initialize(request_class = ActionDispatch::Request)
self.routes = []
self.named_routes = NamedRouteCollection.new
self.resources_path_names = self.class.default_resources_path_names.dup
self.controller_namespaces = Set.new
self.default_url_options = {}
+ self.request_class = request_class
@disable_clear_and_finalize = false
clear!
@@ -232,7 +233,10 @@ module ActionDispatch
@finalized = false
routes.clear
named_routes.clear
- @set = ::Rack::Mount::RouteSet.new(:parameters_key => PARAMETERS_KEY)
+ @set = ::Rack::Mount::RouteSet.new(
+ :parameters_key => PARAMETERS_KEY,
+ :request_class => request_class
+ )
end
def install_helpers(destinations = [ActionController::Base, ActionView::Base], regenerate_code = false)