diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-12-07 18:28:02 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-12-07 18:28:02 -0600 |
commit | 40ad54e3811913c2bc60c7ee292fa48862f12001 (patch) | |
tree | 1262e4052ac27c0694980a2fe19553ff1dab0b39 /actionpack/lib | |
parent | 66375434b6c7e03a396bbeda3f7029dea2a59f23 (diff) | |
download | rails-40ad54e3811913c2bc60c7ee292fa48862f12001.tar.gz rails-40ad54e3811913c2bc60c7ee292fa48862f12001.tar.bz2 rails-40ad54e3811913c2bc60c7ee292fa48862f12001.zip |
Allow scope to take :path and :controller options
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index d9724161a9..fab8a227bf 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -216,6 +216,27 @@ module ActionDispatch def scope(*args) options = args.extract_options! + case args.first + when String + options[:path] = args.first + when Symbol + options[:controller] = args.first + end + + if path = options.delete(:path) + path_set = true + path, @scope[:path] = @scope[:path], "#{@scope[:path]}#{Rack::Mount::Utils.normalize_path(path)}" + else + path_set = false + end + + if controller = options.delete(:controller) + controller_set = true + controller, @scope[:controller] = @scope[:controller], controller + else + controller_set = false + end + constraints = options.delete(:constraints) || {} unless constraints.is_a?(Hash) block, constraints = constraints, {} @@ -225,19 +246,6 @@ module ActionDispatch options, @scope[:options] = @scope[:options], (@scope[:options] || {}).merge(options) - path_set = controller_set = false - - case args.first - when String - path_set = true - path = args.first - path, @scope[:path] = @scope[:path], "#{@scope[:path]}#{Rack::Mount::Utils.normalize_path(path)}" - when Symbol - controller_set = true - controller = args.first - controller, @scope[:controller] = @scope[:controller], controller - end - yield self |