aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/routing/route.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-05-13 01:10:37 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-05-13 12:00:15 -0700
commite8550ee0329586b32de425e905c7af7e65bc78a8 (patch)
tree0cdfe0f9f0d3fb010280ff0453fc553ab6ff2d92 /actionpack/lib/action_controller/routing/route.rb
parentfa5da8ad54d68ea0484825845eb6f6a8e8bca361 (diff)
downloadrails-e8550ee0329586b32de425e905c7af7e65bc78a8.tar.gz
rails-e8550ee0329586b32de425e905c7af7e65bc78a8.tar.bz2
rails-e8550ee0329586b32de425e905c7af7e65bc78a8.zip
Cherry-pick core extensions
Diffstat (limited to 'actionpack/lib/action_controller/routing/route.rb')
-rw-r--r--actionpack/lib/action_controller/routing/route.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/routing/route.rb b/actionpack/lib/action_controller/routing/route.rb
index e2077edad8..eba05a3c5a 100644
--- a/actionpack/lib/action_controller/routing/route.rb
+++ b/actionpack/lib/action_controller/routing/route.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/object/misc'
+
module ActionController
module Routing
class Route #:nodoc:
@@ -65,7 +67,7 @@ module ActionController
# map.connect '/page/:id', :controller => 'pages', :action => 'show', :id => /\d+/
#
def parameter_shell
- @parameter_shell ||= returning({}) do |shell|
+ @parameter_shell ||= {}.tap do |shell|
requirements.each do |key, requirement|
shell[key] = requirement unless requirement.is_a? Regexp
end
@@ -76,7 +78,7 @@ module ActionController
# includes keys that appear inside the path, and keys that have requirements
# placed upon them.
def significant_keys
- @significant_keys ||= returning([]) do |sk|
+ @significant_keys ||= [].tap do |sk|
segments.each { |segment| sk << segment.key if segment.respond_to? :key }
sk.concat requirements.keys
sk.uniq!
@@ -86,7 +88,7 @@ module ActionController
# Return a hash of key/value pairs representing the keys in the route that
# have defaults, or which are specified by non-regexp requirements.
def defaults
- @defaults ||= returning({}) do |hash|
+ @defaults ||= {}.tap do |hash|
segments.each do |segment|
next unless segment.respond_to? :default
hash[segment.key] = segment.default unless segment.default.nil?