diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2013-04-06 11:38:33 -0700 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2013-04-06 11:38:33 -0700 |
commit | 4d8e23463f120f0b057f1b4a10cda9fed809d89b (patch) | |
tree | 06c7158b54d7f9518fc50dfd77d7c23faeac7d42 /actionpack/lib | |
parent | 16b4c3f1fa27aa872ec4b60e9a033eb3aaa4ffaa (diff) | |
parent | 8e295b04f134cd22e754cceb3d9ff710554821c8 (diff) | |
download | rails-4d8e23463f120f0b057f1b4a10cda9fed809d89b.tar.gz rails-4d8e23463f120f0b057f1b4a10cda9fed809d89b.tar.bz2 rails-4d8e23463f120f0b057f1b4a10cda9fed809d89b.zip |
Merge pull request #10101 from wangjohn/refactoring_routing_mapper
Refactoring some reused code into a method (inside of the routes mapper)
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 45d2d3346e..8c095d605a 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -10,6 +10,9 @@ module ActionDispatch module Routing class Mapper URL_OPTIONS = [:protocol, :subdomain, :domain, :host, :port] + SCOPE_OPTIONS = [:path, :shallow_path, :as, :shallow_prefix, :module, + :controller, :path_names, :constraints, :defaults, + :shallow, :blocks, :options] class Constraints #:nodoc: def self.new(app, constraints, request = Rack::Request) @@ -697,19 +700,21 @@ module ActionDispatch block, options[:constraints] = options[:constraints], {} end - scope_options.each do |option| - if value = options.delete(option) + SCOPE_OPTIONS.each do |option| + if option == :blocks + value = block + elsif option == :options + value = options + else + value = options.delete(option) + end + + if value recover[option] = @scope[option] @scope[option] = send("merge_#{option}_scope", @scope[option], value) end end - recover[:blocks] = @scope[:blocks] - @scope[:blocks] = merge_blocks_scope(@scope[:blocks], block) - - recover[:options] = @scope[:options] - @scope[:options] = merge_options_scope(@scope[:options], options) - yield self ensure @@ -840,10 +845,6 @@ module ActionDispatch end private - def scope_options #:nodoc: - @scope_options ||= private_methods.grep(/^merge_(.+)_scope$/) { $1.to_sym } - end - def merge_path_scope(parent, child) #:nodoc: Mapper.normalize_path("#{parent}/#{child}") end |