diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-02-24 16:01:03 -0800 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-02-25 17:53:00 -0800 |
commit | 226dfc2681c98deaf14e4ae82e973d1d5caedd68 (patch) | |
tree | df761036bb714f3b9c10bb1eced20322aad953a7 /actionpack/lib/action_dispatch/routing/route_set.rb | |
parent | 76237f163ff7ad2a64af926030e3449c547cafa2 (diff) | |
download | rails-226dfc2681c98deaf14e4ae82e973d1d5caedd68.tar.gz rails-226dfc2681c98deaf14e4ae82e973d1d5caedd68.tar.bz2 rails-226dfc2681c98deaf14e4ae82e973d1d5caedd68.zip |
WIP: Remove the global router
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/route_set.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 8778fd2932..8b761d393f 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -272,6 +272,36 @@ module ActionDispatch named_routes.install(destinations, regenerate_code) end + # ROUTES TODO: Revisit the name of these methods + def url_helpers + @url_helpers ||= begin + router = self + Module.new do + extend ActiveSupport::Concern + include UrlFor + + define_method(:_router) { router } + end + end + end + + def named_url_helpers + @named_url_helpers ||= begin + router = self + + Module.new do + extend ActiveSupport::Concern + include router.url_helpers + + # ROUTES TODO: install_helpers isn't great... can we make a module with the stuff that + # we can include? + included do + router.install_helpers(self) + end + end + end + end + def empty? routes.empty? end |