From fd71a1a354f96a74556346920ff61e80b91d8af0 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 8 Sep 2008 19:42:20 -0700 Subject: Remove recognized_optimized method before redefining it --- .../routing/recognition_optimisation.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/routing/recognition_optimisation.rb b/actionpack/lib/action_controller/routing/recognition_optimisation.rb index 306219a431..4935432d87 100644 --- a/actionpack/lib/action_controller/routing/recognition_optimisation.rb +++ b/actionpack/lib/action_controller/routing/recognition_optimisation.rb @@ -134,6 +134,9 @@ module ActionController def write_recognize_optimized! tree = segment_tree(routes) body = generate_code(tree) + + remove_recognize_optimized! + instance_eval %{ def recognize_optimized(path, env) segments = to_plain_segments(path) @@ -149,12 +152,22 @@ module ActionController end def clear_recognize_optimized! - instance_eval %{ + remove_recognize_optimized! + + class << self def recognize_optimized(path, environment) write_recognize_optimized! recognize_optimized(path, environment) end - }, __FILE__, __LINE__ + end + end + + def remove_recognize_optimized! + if respond_to?(:recognize_optimized) + class << self + remove_method :recognize_optimized + end + end end end end -- cgit v1.2.3