From 3abf5ad7f8b23d955225ba96e82fd5565dd2571d Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 16 Mar 2010 12:38:37 -0700 Subject: 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. --- actionpack/lib/action_dispatch/routing/route_set.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'actionpack/lib/action_dispatch') 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 -- cgit v1.2.3