Skip to content
This repository
Browse code

RouteSet: remove some code dups

  • Loading branch information...
commit da88d800b8e67841af8b4270c13bcac4559b6f74 1 parent 02f2e3d
Bogdan Gusiev bogdan authored

Showing 1 changed file with 10 additions and 19 deletions. Show diff stats Hide diff stats

  1. +10 19 actionpack/lib/action_dispatch/routing/route_set.rb
29 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -184,27 +184,18 @@ def define_named_route_methods(name, route)
184 184 def define_url_helper(route, name, options)
185 185 selector = url_helper_name(name, options[:only_path])
186 186
187   - if optimize_helper?(route)
188   - @module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1
189   - remove_possible_method :#{selector}
190   - def #{selector}(*args)
191   - if args.size == #{route.required_parts.size} && !args.last.is_a?(Hash) && optimize_routes_generation?
192   - options = #{options.inspect}.merge!(url_options)
193   - options[:path] = "#{optimized_helper(route)}"
194   - ActionDispatch::Http::URL.url_for(options)
195   - else
196   - url_for(handle_positional_args(args, #{options.inspect}, #{route.segment_keys.inspect}))
197   - end
198   - end
199   - END_EVAL
200   - else
201   - @module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1
202   - remove_possible_method :#{selector}
203   - def #{selector}(*args)
  187 + @module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1
  188 + remove_possible_method :#{selector}
  189 + def #{selector}(*args)
  190 + if #{optimize_helper?(route)} && args.size == #{route.required_parts.size} && !args.last.is_a?(Hash) && optimize_routes_generation?
  191 + options = #{options.inspect}.merge!(url_options)
  192 + options[:path] = "#{optimized_helper(route)}"
  193 + ActionDispatch::Http::URL.url_for(options)
  194 + else
204 195 url_for(handle_positional_args(args, #{options.inspect}, #{route.segment_keys.inspect}))
205 196 end
206   - END_EVAL
207   - end
  197 + end
  198 + END_EVAL
208 199
209 200 helpers << selector
210 201 end

0 comments on commit da88d80

Please sign in to comment.
Something went wrong with that request. Please try again.