Skip to content

Commit

Permalink
make the module version quack the same as the instance
Browse files Browse the repository at this point in the history
this way we can stop checking respond_to on every call.
  • Loading branch information
tenderlove committed May 12, 2014
1 parent eacb426 commit ffa53ff
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions actionpack/lib/action_dispatch/routing/route_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ffa53ff

Please sign in to comment.