Skip to content

Commit

Permalink
don't use instance eval, just reference variables so we don't have to
Browse files Browse the repository at this point in the history
worry about "inspect" marshalling
  • Loading branch information
tenderlove committed Dec 29, 2011
1 parent 04d308a commit 0035c54
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions actionpack/lib/action_dispatch/routing/route_set.rb
Expand Up @@ -149,22 +149,23 @@ def define_named_route_methods(name, route)
def define_hash_access(route, name, kind, options) def define_hash_access(route, name, kind, options)
selector = hash_access_name(name, kind) selector = hash_access_name(name, kind)


# We use module_eval to avoid leaks @module.module_eval do
@module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1 remove_possible_method selector
remove_possible_method :#{selector}
def #{selector}(*args) define_method(selector) do |*args|
options = args.extract_options! inner_options = args.extract_options!
result = #{options.inspect} result = options.dup


if args.any? if args.any?
result[:_positional_args] = args result[:_positional_args] = args
result[:_positional_keys] = #{route.segment_keys.inspect} result[:_positional_keys] = route.segment_keys
end end


result.merge(options) result.merge(inner_options)
end end
protected :#{selector}
END_EVAL protected selector
end
helpers << selector helpers << selector
end end


Expand Down

0 comments on commit 0035c54

Please sign in to comment.