diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-29 10:25:58 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-29 10:25:58 -0800 |
commit | 0035c54e2f5b0d5b4d27d50d16fb91bad4060c5a (patch) | |
tree | a0a79062cb6563c28266ae17d51405b83d2f1314 /actionpack | |
parent | 04d308a03bbd904bac62f9c5453da37de940adc6 (diff) | |
download | rails-0035c54e2f5b0d5b4d27d50d16fb91bad4060c5a.tar.gz rails-0035c54e2f5b0d5b4d27d50d16fb91bad4060c5a.tar.bz2 rails-0035c54e2f5b0d5b4d27d50d16fb91bad4060c5a.zip |
don't use instance eval, just reference variables so we don't have to
worry about "inspect" marshalling
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 3b9d8dc57b..3ffa4b4bea 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -149,22 +149,23 @@ module ActionDispatch def define_hash_access(route, name, kind, options) selector = hash_access_name(name, kind) - # We use module_eval to avoid leaks - @module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1 - remove_possible_method :#{selector} - def #{selector}(*args) - options = args.extract_options! - result = #{options.inspect} + @module.module_eval do + remove_possible_method selector + + define_method(selector) do |*args| + inner_options = args.extract_options! + result = options.dup if args.any? result[:_positional_args] = args - result[:_positional_keys] = #{route.segment_keys.inspect} + result[:_positional_keys] = route.segment_keys end - result.merge(options) + result.merge(inner_options) end - protected :#{selector} - END_EVAL + + protected selector + end helpers << selector end |