aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-05-12 09:47:46 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-05-12 14:22:10 -0700
commitffa53ffd4395cb9dc414f0d01cff27e9d18dd8f3 (patch)
tree835950ec2d32ea02b2b19e76e48c4fda38ec7bbd
parenteacb4264af7593a41487625d5a7a6f6986c58b47 (diff)
downloadrails-ffa53ffd4395cb9dc414f0d01cff27e9d18dd8f3.tar.gz
rails-ffa53ffd4395cb9dc414f0d01cff27e9d18dd8f3.tar.bz2
rails-ffa53ffd4395cb9dc414f0d01cff27e9d18dd8f3.zip
make the module version quack the same as the instance
this way we can stop checking respond_to on every call.
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 440193cb42..d61b430f68 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -172,7 +172,7 @@ module ActionDispatch
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 @@ module ActionDispatch
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 @@ module ActionDispatch
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 @@ module ActionDispatch
@_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