This patch modifies RouteSet#write_generation and RouteSet#write_recognition...

This patch modifies RouteSet#write_generation and RouteSet#write_recognition so that they return the source code used to recognize or generate URLs. #1531 [Nicholas Seckar]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1551 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 c92ecb82
......@@ -388,6 +388,7 @@ def generate_default_path(*args)
end
def write_generation
method_sources = []
@generation_methods = Hash.new(:generate_default_path)
categorize_routes.each do |controller, routes|
next unless routes.length < @routes.length
......@@ -396,6 +397,7 @@ def write_generation
method_name = "generate_path_for_#{ivar}".to_sym
instance_variable_set "@#{ivar}", routes
code = generation_code_for(ivar, method_name).to_s
method_sources &lt;&lt; code
filename = "generated_code/routing/generation_for_controller_#{controller}.rb"
eval(code, nil, filename)
......@@ -404,7 +406,11 @@ def write_generation
@generation_methods[controller.to_sym] = method_name
end
eval(generation_code_for('routes', 'generate_default_path').to_s, nil, 'generated_code/routing/generation.rb')
code = generation_code_for('routes', 'generate_default_path').to_s
eval(code, nil, 'generated_code/routing/generation.rb')
return (method_sources &lt;&lt; code)
end
def recognize(request)
......@@ -439,6 +445,7 @@ def write_recognition
end
eval g.to_s, nil, 'generated/routing/recognition.rb'
return g.to_s
end
def generation_code_for(ivar = 'routes', method_name = nil)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册