aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-08-12 16:54:24 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-08-12 16:54:35 -0700
commit39556884403ab5baa89574671f1a100c42792b02 (patch)
treeb7621a67fa97b5389edc5aefeb78138a34a98edd /actionpack
parentec895189e4bed93f40ba96af7319a5fc046ad621 (diff)
downloadrails-39556884403ab5baa89574671f1a100c42792b02.tar.gz
rails-39556884403ab5baa89574671f1a100c42792b02.tar.bz2
rails-39556884403ab5baa89574671f1a100c42792b02.zip
pull `format` out of the options hash
remove `format` from the options hash in the scope chain so that we don't need to remove it later
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb21
1 files changed, 10 insertions, 11 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index af4c7eb564..29daf39aec 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -67,7 +67,6 @@ module ActionDispatch
options.delete :shallow_path
options.delete :shallow_prefix
options.delete :shallow
- options.delete :format
defaults = (scope[:defaults] || {}).dup
scope_constraints = scope[:constraints] || {}
@@ -808,10 +807,10 @@ module ActionDispatch
elsif option == :options
value = options
else
- value = options.delete(option)
+ value = options.delete(option) { POISON }
end
- if value
+ unless POISON == value
scope[option] = send("merge_#{option}_scope", @scope[option], value)
end
end
@@ -823,6 +822,8 @@ module ActionDispatch
@scope = @scope.parent
end
+ POISON = Object.new # :nodoc:
+
# Scopes routes to a specific controller
#
# controller "food" do
@@ -992,6 +993,10 @@ module ActionDispatch
child
end
+ def merge_format_scope(parent, child) #:nodoc:
+ child
+ end
+
def merge_path_names_scope(parent, child) #:nodoc:
merge_options_scope(parent, child)
end
@@ -1549,7 +1554,7 @@ module ActionDispatch
via = Mapping.check_via Array(options.delete(:via) {
@scope[:via]
})
- formatted = options.delete(:format) { @scope.mapping_option(:format) }
+ formatted = options.delete(:format) { @scope[:format] }
path_types = paths.group_by(&:class)
path_types.fetch(String, []).each do |_path|
@@ -1942,7 +1947,7 @@ module ActionDispatch
class Scope # :nodoc:
OPTIONS = [:path, :shallow_path, :as, :shallow_prefix, :module,
:controller, :action, :path_names, :constraints,
- :shallow, :blocks, :defaults, :via, :options]
+ :shallow, :blocks, :defaults, :via, :format, :options]
RESOURCE_SCOPES = [:resource, :resources]
RESOURCE_METHOD_SCOPES = [:collection, :member, :new]
@@ -1992,12 +1997,6 @@ module ActionDispatch
OPTIONS
end
- def mapping_option(name)
- options = self[:options]
- return unless options
- options[name]
- end
-
def new(hash)
self.class.new hash, self, scope_level
end