diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-12 15:30:43 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-12 15:30:43 -0700 |
commit | 33d20ea18474e5c7a14d72fcbafc0c63bf812aba (patch) | |
tree | 31366ad81c8ed05ae94d69406f7f4ebc20bfa0c3 | |
parent | e2735b2b32db5de76c39d953b1e6339ecb19e24d (diff) | |
download | rails-33d20ea18474e5c7a14d72fcbafc0c63bf812aba.tar.gz rails-33d20ea18474e5c7a14d72fcbafc0c63bf812aba.tar.bz2 rails-33d20ea18474e5c7a14d72fcbafc0c63bf812aba.zip |
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
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 17 |
1 files changed, 8 insertions, 9 deletions
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: |