diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2006-07-17 17:03:47 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2006-07-17 17:03:47 +0000 |
commit | 378a93543092c95331beac53af56c476284564aa (patch) | |
tree | 064e9d496ec894eb7872f57ec56e3c6fe13fd11e /actionpack/lib/action_controller | |
parent | 2482e17e5794b1728b1208aa1eaf58cef3aa0ab0 (diff) | |
download | rails-378a93543092c95331beac53af56c476284564aa.tar.gz rails-378a93543092c95331beac53af56c476284564aa.tar.bz2 rails-378a93543092c95331beac53af56c476284564aa.zip |
Remove leak in development mode
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4611 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index f374fff02f..a91019d418 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -858,9 +858,11 @@ module ActionController def define_hash_access(route, name, kind, options) selector = hash_access_name(name, kind) - @module.send(:define_method, selector) do |*args| - args.first ? options.merge(args.first) : options - end + @module.send :module_eval, <<-end_eval # We use module_eval to avoid leaks + def #{selector}(options = nil) + options ? #{options.inspect}.merge(options) : #{options.inspect} + end + end_eval @module.send(:protected, selector) helpers << selector end @@ -874,26 +876,28 @@ module ActionController end.compact hash_access_method = hash_access_name(name, kind) - @module.send(:define_method, selector) do |*args| - opts = if args.empty? || Hash === args.first - args.first || {} - else - # allow ordered parameters to be associated with corresponding - # dynamic segments, so you can do - # - # foo_url(bar, baz, bang) - # - # instead of - # - # foo_url(:bar => bar, :baz => baz, :bang => bang) - args.zip(segment_keys).inject({}) do |h, (v, k)| - h[k] = v - h + @module.send :module_eval, <<-end_eval # We use module_eval to avoid leaks + def #{selector}(*args) + opts = if args.empty? || Hash === args.first + args.first || {} + else + # allow ordered parameters to be associated with corresponding + # dynamic segments, so you can do + # + # foo_url(bar, baz, bang) + # + # instead of + # + # foo_url(:bar => bar, :baz => baz, :bang => bang) + args.zip(#{segment_keys.inspect}).inject({}) do |h, (v, k)| + h[k] = v + h + end end + + url_for(#{hash_access_method}(opts)) end - - url_for(send(hash_access_method, opts)) - end + end_eval @module.send(:protected, selector) helpers << selector end |