aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2010-03-16 12:38:37 -0700
committerCarlhuda <carlhuda@engineyard.com>2010-03-16 15:47:48 -0700
commit3abf5ad7f8b23d955225ba96e82fd5565dd2571d (patch)
treef68094e25b06c79c0c25e2cf07536320ed2d2b92 /actionpack/lib/action_dispatch
parent56fb60ebfe9a20ced1366f3e35b2f9bd0bac8e45 (diff)
downloadrails-3abf5ad7f8b23d955225ba96e82fd5565dd2571d.tar.gz
rails-3abf5ad7f8b23d955225ba96e82fd5565dd2571d.tar.bz2
rails-3abf5ad7f8b23d955225ba96e82fd5565dd2571d.zip
Make RouteSet#finalize! a NOOP if it's been called already. Call finalize! the first time call() and url_for() are called if the RouteSet has not been finalized yet.
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 722be432c7..048764263e 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -219,6 +219,8 @@ module ActionDispatch
end
def finalize!
+ return if @finalized
+ @finalized = true
@set.add_route(NotFound)
install_helpers
@set.freeze
@@ -227,6 +229,7 @@ module ActionDispatch
def clear!
# Clear the controller cache so we may discover new ones
@controller_constraints = nil
+ @finalized = false
routes.clear
named_routes.clear
@set = ::Rack::Mount::RouteSet.new(:parameters_key => PARAMETERS_KEY)
@@ -406,6 +409,7 @@ module ActionDispatch
RESERVED_OPTIONS = [:anchor, :params, :only_path, :host, :protocol, :port, :trailing_slash]
def url_for(options)
+ finalize!
options = default_url_options.merge(options || {})
handle_positional_args(options)
@@ -437,6 +441,7 @@ module ActionDispatch
end
def call(env)
+ finalize!
@set.call(env)
end