aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/url_for.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/metal/url_for.rb')
-rw-r--r--actionpack/lib/action_controller/metal/url_for.rb30
1 files changed, 14 insertions, 16 deletions
diff --git a/actionpack/lib/action_controller/metal/url_for.rb b/actionpack/lib/action_controller/metal/url_for.rb
index 0b40b1fc4c..4504d9cd10 100644
--- a/actionpack/lib/action_controller/metal/url_for.rb
+++ b/actionpack/lib/action_controller/metal/url_for.rb
@@ -1,7 +1,7 @@
-# Includes +url_for+ into the host class. The class has to provide a +RouteSet+ by implementing
+# Includes +url_for+ into the host class. The class has to provide a +RouteSet+ by implementing
# the <tt>_routes</tt> method. Otherwise, an exception will be raised.
#
-# In addition to <tt>AbstractController::UrlFor</tt>, this module accesses the HTTP layer to define
+# In addition to <tt>AbstractController::UrlFor</tt>, this module accesses the HTTP layer to define
# url options like the +host+. In order to do so, this module requires the host class
# to implement +env+ and +request+, which need to be a Rack-compatible.
#
@@ -18,7 +18,7 @@
# @url = root_path # named route from the application.
# end
# end
-#
+#
module ActionController
module UrlFor
extend ActiveSupport::Concern
@@ -26,22 +26,20 @@ module ActionController
include AbstractController::UrlFor
def url_options
- @_url_options ||= super.reverse_merge(
- :host => request.host,
- :port => request.optional_port,
- :protocol => request.protocol,
- :_path_segments => request.symbolized_path_parameters
- ).freeze
+ @_url_options ||= begin
+ hash = super.reverse_merge(
+ :host => request.host,
+ :port => request.optional_port,
+ :protocol => request.protocol,
+ :_path_segments => request.symbolized_path_parameters
+ )
- if _routes.equal?(env["action_dispatch.routes"])
- @_url_options.dup.tap do |options|
- options[:script_name] = request.script_name.dup
- options.freeze
+ if _routes.equal?(env["action_dispatch.routes"])
+ hash[:script_name] = request.script_name.dup
end
- else
- @_url_options
+
+ hash.freeze
end
end
-
end
end