From b1c66f060bba22d16abf6d24d3df762c240e367c Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 25 Aug 2010 13:41:56 +0200 Subject: Move RoutesProxy to separate file --- .../lib/action_dispatch/routing/routes_proxy.rb | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 actionpack/lib/action_dispatch/routing/routes_proxy.rb (limited to 'actionpack/lib/action_dispatch/routing/routes_proxy.rb') diff --git a/actionpack/lib/action_dispatch/routing/routes_proxy.rb b/actionpack/lib/action_dispatch/routing/routes_proxy.rb new file mode 100644 index 0000000000..f7d5f6397d --- /dev/null +++ b/actionpack/lib/action_dispatch/routing/routes_proxy.rb @@ -0,0 +1,35 @@ +module ActionDispatch + module Routing + class RoutesProxy #:nodoc: + include ActionDispatch::Routing::UrlFor + + attr_accessor :scope, :routes + alias :_routes :routes + + def initialize(routes, scope) + @routes, @scope = routes, scope + end + + def url_options + scope.send(:_with_routes, routes) do + scope.url_options + end + end + + def method_missing(method, *args) + if routes.url_helpers.respond_to?(method) + self.class.class_eval <<-RUBY, __FILE__, __LINE__ + 1 + def #{method}(*args) + options = args.extract_options! + args << url_options.merge((options || {}).symbolize_keys) + routes.url_helpers.#{method}(*args) + end + RUBY + send(method, *args) + else + super + end + end + end + end +end -- cgit v1.2.3