diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-30 16:05:27 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-03 11:33:54 -0700 |
commit | af1c8665cd9b5157a22c1f3dd3ddd4cbde31f9a1 (patch) | |
tree | 058021aa91df3fc5f06c695a6477d4c28d341d99 /actionpack/lib/action_dispatch/routing | |
parent | a21707116aab2a0b1038c719635eaf3d737ad644 (diff) | |
download | rails-af1c8665cd9b5157a22c1f3dd3ddd4cbde31f9a1.tar.gz rails-af1c8665cd9b5157a22c1f3dd3ddd4cbde31f9a1.tar.bz2 rails-af1c8665cd9b5157a22c1f3dd3ddd4cbde31f9a1.zip |
push some options munging to an alternate constructor
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index c588cafebd..0b13738dcb 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -65,15 +65,27 @@ module ActionDispatch attr_reader :requirements, :conditions, :defaults attr_reader :to, :default_controller, :default_action, :as, :anchor - def initialize(scope, path, options) - @requirements, @conditions = {}, {} + def self.build(scope, path, options) + 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 - @defaults = (scope[:defaults] || {}).merge options.delete(:defaults) || {} + defaults = (scope[:defaults] || {}).merge options.delete(:defaults) || {} + + new scope, path, defaults, options + end + + def initialize(scope, path, defaults, options) + @requirements, @conditions = {}, {} + @defaults = defaults - options = scope[:options].merge(options) if scope[:options] @to = options.delete :to - @default_controller = options[:controller] || scope[:controller] - @default_action = options[:action] || scope[:action] + @default_controller = options.delete(:controller) || scope[:controller] + @default_action = options.delete(:action) || scope[:action] @as = options.delete :as @anchor = options.delete :anchor @@ -1516,13 +1528,7 @@ module ActionDispatch options[:as] = name_for_action(options[:as], action) end - options.delete :only - options.delete :except - options.delete :shallow_path - options.delete :shallow_prefix - options.delete :shallow - - mapping = Mapping.new(@scope, URI.parser.escape(path), options) + mapping = Mapping.build(@scope, URI.parser.escape(path), options) app, conditions, requirements, defaults, as, anchor = mapping.to_route @set.add_route(app, conditions, requirements, defaults, as, anchor) end |