aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/url_for.rb
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-02-25 15:05:10 -0800
committerCarlhuda <carlhuda@engineyard.com>2010-02-25 17:53:01 -0800
commit36fd9efb5e4bfc9ac3acd4189d4dc457dea8102a (patch)
treeee50b242b16d4d4a5c98a2d48f5b0af2d46e5ce0 /actionpack/lib/action_dispatch/routing/url_for.rb
parent9a5be2e5a80ab9e74294f32cfef58fbbcd9b637c (diff)
downloadrails-36fd9efb5e4bfc9ac3acd4189d4dc457dea8102a.tar.gz
rails-36fd9efb5e4bfc9ac3acd4189d4dc457dea8102a.tar.bz2
rails-36fd9efb5e4bfc9ac3acd4189d4dc457dea8102a.zip
Continued effort to deglobalize the router
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/url_for.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/url_for.rb31
1 files changed, 7 insertions, 24 deletions
diff --git a/actionpack/lib/action_dispatch/routing/url_for.rb b/actionpack/lib/action_dispatch/routing/url_for.rb
index 64c695fe13..1d6da817ed 100644
--- a/actionpack/lib/action_dispatch/routing/url_for.rb
+++ b/actionpack/lib/action_dispatch/routing/url_for.rb
@@ -85,8 +85,6 @@ module ActionDispatch
extend ActiveSupport::Concern
included do
- # ActionDispatch::Routing::Routes.install_helpers(self)
-
# Including in a class uses an inheritable hash. Modules get a plain hash.
if respond_to?(:class_attribute)
class_attribute :default_url_options
@@ -97,23 +95,16 @@ module ActionDispatch
self.default_url_options = {}
end
- # Overwrite to implement a number of default options that all url_for-based methods will use. The default options should come in
- # the form of a hash, just like the one you would use for url_for directly. Example:
- #
- # def default_url_options(options)
- # { :project => @project.active? ? @project.url_name : "unknown" }
- # end
- #
- # As you can infer from the example, this is mostly useful for situations where you want to centralize dynamic decisions about the
- # urls as they stem from the business domain. Please note that any individual url_for call can always override the defaults set
- # by this method.
def default_url_options(options = nil)
- # ROUTES TODO: This should probably be an instance method
self.class.default_url_options
end
- def rewrite_options(options) #:nodoc:
- if options.delete(:use_defaults) != false && (defaults = default_url_options(options))
+ def url_options
+ self.class.default_url_options.merge
+ end
+
+ def merge_options(options) #:nodoc:
+ if options.delete(:use_defaults) != false && respond_to?(:default_url_options) && (defaults = default_url_options(options))
defaults.merge(options)
else
options
@@ -149,19 +140,11 @@ module ActionDispatch
when String
options
when Hash
- _url_rewriter.rewrite(_router, rewrite_options(options))
+ ActionController::UrlRewriter.rewrite(_router, merge_options(options))
else
polymorphic_url(options)
end
end
-
- protected
-
- # ROUTES TODO: Figure out why _url_rewriter is sometimes the class and
- # sometimes an instance.
- def _url_rewriter
- ActionController::UrlRewriter
- end
end
end
end \ No newline at end of file