Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

moved more evald code

  • Loading branch information...
commit 44dd44ad7018badf4fe95f93675af2a6d5587df4 1 parent fc8f45a
@tenderlove tenderlove authored
Showing with 7 additions and 8 deletions.
  1. +7 −8 actionpack/lib/action_dispatch/routing/route_set.rb
View
15 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -172,6 +172,12 @@ def url_else(t, args, options, seg)
t.url_for(handle_positional_args(t, args, options, seg))
end
+ def url_if(t, options, path)
+ options.merge!(t.url_options) if t.respond_to?(:url_options)
+ options[:path] = path
+ ActionDispatch::Http::URL.url_for(options)
+ end
+
def handle_positional_args(t, args, options, segment_keys)
inner_options = args.extract_options!
result = options.dup
@@ -192,17 +198,10 @@ def handle_positional_args(t, args, options, segment_keys)
def define_url_helper(route, name, options)
@module.remove_possible_method name
@module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1
-
- def if_#{name}(t, options, path)
- options.merge!(url_options) if t.respond_to?(:url_options)
- options[:path] = path
- ActionDispatch::Http::URL.url_for(options)
- end
-
def #{name}(*args)
if #{optimize_helper?(route)} && args.size == #{route.required_parts.size} && !args.last.is_a?(Hash) && optimize_routes_generation?
options = #{options.inspect}
- if_#{name}(self, options, "#{optimized_helper(route)}")
+ UrlHelp.new.url_if(self, options, "#{optimized_helper(route)}")
else
UrlHelp.new.url_else(self, args, #{options.inspect}, #{route.segment_keys.inspect})
end
Please sign in to comment.
Something went wrong with that request. Please try again.