From 33d20ea18474e5c7a14d72fcbafc0c63bf812aba Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 12 Aug 2015 15:30:43 -0700 Subject: store `:only` and `:except` outside the normal options hash these two keys have a different merge strategy, and they also just get removed from the options hash later in the code. If we store them in a separate place, then we don't need to remove them later --- actionpack/lib/action_dispatch/routing/mapper.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 6e1db3b492..baaa374c6b 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -66,8 +66,6 @@ module ActionDispatch options = scope[:options].merge(options) if scope[:options] - options.delete :only - options.delete :except options.delete :shallow_path options.delete :shallow_prefix options.delete :shallow @@ -802,6 +800,11 @@ module ActionDispatch block, options[:constraints] = options[:constraints], {} end + if options.key?(:only) || options.key?(:except) + scope[:action_options] = { only: options.delete(:only), + except: options.delete(:except) } + end + @scope.options.each do |option| if option == :blocks value = block @@ -1007,16 +1010,12 @@ module ActionDispatch end def merge_options_scope(parent, child) #:nodoc: - (parent || {}).except(*override_keys(child)).merge!(child) + (parent || {}).merge(child) end def merge_shallow_scope(parent, child) #:nodoc: child ? true : false end - - def override_keys(child) #:nodoc: - child.key?(:only) || child.key?(:except) ? [:only, :except] : [] - end end # Resource routing allows you to quickly declare all of the common routes @@ -1684,11 +1683,11 @@ module ActionDispatch end def scope_action_options? #:nodoc: - @scope[:options] && (@scope[:options][:only] || @scope[:options][:except]) + @scope[:action_options] end def scope_action_options #:nodoc: - @scope[:options].slice(:only, :except) + @scope[:action_options] end def resource_scope? #:nodoc: -- cgit v1.2.3