From 39556884403ab5baa89574671f1a100c42792b02 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 12 Aug 2015 16:54:24 -0700 Subject: 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 --- actionpack/lib/action_dispatch/routing/mapper.rb | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'actionpack') 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 -- cgit v1.2.3