Permalink
Browse files

make the module version quack the same as the instance

this way we can stop checking respond_to on every call.
  • Loading branch information...
1 parent eacb426 commit ffa53ffd4395cb9dc414f0d01cff27e9d18dd8f3 @tenderlove tenderlove committed May 12, 2014
Showing with 10 additions and 3 deletions.
  1. +10 −3 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -172,7 +172,7 @@ def initialize(route, options)
def call(t, args)
if args.size == arg_size && !args.last.is_a?(Hash) && optimize_routes_generation?(t)
options = @options.dup
- options.merge!(t.url_options) if t.respond_to?(:url_options)
+ options.merge!(t.url_options)
options[:path] = optimized_helper(args)
ActionDispatch::Http::URL.url_for(options)
else
@@ -225,7 +225,12 @@ def initialize(route, options)
end
def call(t, args)
- t.url_for(handle_positional_args(t, args, @options, @segment_keys))
+ options = handle_positional_args(t, args, @options, @segment_keys)
+ hash = {
+ :only_path => options[:host].nil?
+ }.merge!(options.symbolize_keys)
+ hash.reverse_merge!(t.url_options)
+ t._routes.url_for(hash)
end
def handle_positional_args(t, args, options, keys)
@@ -234,7 +239,7 @@ def handle_positional_args(t, args, options, keys)
if args.size > 0
if args.size < keys.size - 1 # take format into account
- keys -= t.url_options.keys if t.respond_to?(:url_options)
+ keys -= t.url_options.keys
keys -= options.keys
end
keys -= inner_options.keys
@@ -393,6 +398,8 @@ def url_helpers
@_routes = routes
class << self
delegate :url_for, :optimize_routes_generation?, :to => '@_routes'
+ attr_reader :_routes
+ def url_options; {}; end
end
# Make named_routes available in the module singleton

0 comments on commit ffa53ff

Please sign in to comment.