1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/lib/action_dispatch/routing/routes_proxy.rb
2010-09-03 22:59:13 +02:00

35 lines
873 B
Ruby

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