public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
dryed up resources; fixed small formatting issue in resources rdoc

Signed-off-by: Michael Koziarski <michael@koziarski.com>
gcnovus (author)
Fri Jun 13 03:49:10 -0700 2008
NZKoz (committer)
Fri Aug 08 01:47:26 -0700 2008
commit  14cf9a89919b72df301016e4596855c2112c6cef
tree    f5ed967e87e7d13699ae4dba3a9507c30898e8b6
parent  1db7c9cf4a153bbc9001d69508f58b3e8b288c34
...
14
15
16
17
18
19
20
 
 
 
 
21
22
23
...
481
482
483
484
485
 
486
487
488
...
495
496
497
498
499
 
500
501
502
503
 
504
505
506
507
508
509
 
510
511
512
...
514
515
516
517
518
 
519
520
521
 
522
523
524
...
532
533
534
535
536
 
537
538
539
540
541
542
 
543
544
545
546
 
547
548
549
550
 
 
 
 
 
 
 
 
 
 
 
551
552
553
...
574
575
576
577
 
578
...
14
15
16
 
 
 
 
17
18
19
20
21
22
23
...
481
482
483
 
 
484
485
486
487
...
494
495
496
 
 
497
498
499
 
 
500
501
502
503
504
 
 
505
506
507
508
...
510
511
512
 
 
513
514
 
 
515
516
517
518
...
526
527
528
 
 
529
530
531
532
533
 
 
534
535
536
 
 
537
538
539
 
 
540
541
542
543
544
545
546
547
548
549
550
551
552
553
...
574
575
576
 
577
578
0
@@ -14,10 +14,10 @@ module ActionController
0
   #
0
   # === The Different Methods and their Usage
0
   #
0
-  # +GET+     Requests for a resource, no saving or editing of a resource should occur in a GET request
0
-  # +POST+    Creation of resources
0
-  # +PUT+     Editing of attributes on a resource
0
-  # +DELETE+  Deletion of a resource
0
+  # [+GET+]     Requests for a resource, no saving or editing of a resource should occur in a GET request
0
+  # [+POST+]    Creation of resources
0
+  # [+PUT+]     Editing of attributes on a resource
0
+  # [+DELETE+]  Deletion of a resource
0
   #
0
   # === Examples
0
   #
0
@@ -481,8 +481,7 @@ module ActionController
0
         resource.collection_methods.each do |method, actions|
0
           actions.each do |action|
0
             action_options = action_options_for(action, resource, method)
0
-            map.named_route("#{action}_#{resource.name_prefix}#{resource.plural}", "#{resource.path}#{resource.action_separator}#{action}", action_options)
0
-            map.named_route("formatted_#{action}_#{resource.name_prefix}#{resource.plural}", "#{resource.path}#{resource.action_separator}#{action}.:format", action_options)
0
+            map_named_routes(map, "#{action}_#{resource.name_prefix}#{resource.plural}", "#{resource.path}#{resource.action_separator}#{action}", action_options)
0
           end
0
         end
0
       end
0
@@ -495,18 +494,15 @@ module ActionController
0
           index_route_name << "_index"
0
         end
0
 
0
-        map.named_route(index_route_name, resource.path, index_action_options)
0
-        map.named_route("formatted_#{index_route_name}", "#{resource.path}.:format", index_action_options)
0
+        map_named_routes(map, index_route_name, resource.path, index_action_options)
0
 
0
         create_action_options = action_options_for("create", resource)
0
-        map.connect(resource.path, create_action_options)
0
-        map.connect("#{resource.path}.:format", create_action_options)
0
+        map_unnamed_routes(map, resource.path, create_action_options)
0
       end
0
 
0
       def map_default_singleton_actions(map, resource)
0
         create_action_options = action_options_for("create", resource)
0
-        map.connect(resource.path, create_action_options)
0
-        map.connect("#{resource.path}.:format", create_action_options)
0
+        map_unnamed_routes(map, resource.path, create_action_options)
0
       end
0
 
0
       def map_new_actions(map, resource)
0
@@ -514,11 +510,9 @@ module ActionController
0
           actions.each do |action|
0
             action_options = action_options_for(action, resource, method)
0
             if action == :new
0
-              map.named_route("new_#{resource.name_prefix}#{resource.singular}", resource.new_path, action_options)
0
-              map.named_route("formatted_new_#{resource.name_prefix}#{resource.singular}", "#{resource.new_path}.:format", action_options)
0
+              map_named_routes(map, "new_#{resource.name_prefix}#{resource.singular}", resource.new_path, action_options)
0
             else
0
-              map.named_route("#{action}_new_#{resource.name_prefix}#{resource.singular}", "#{resource.new_path}#{resource.action_separator}#{action}", action_options)
0
-              map.named_route("formatted_#{action}_new_#{resource.name_prefix}#{resource.singular}", "#{resource.new_path}#{resource.action_separator}#{action}.:format", action_options)
0
+              map_named_routes(map, "#{action}_new_#{resource.name_prefix}#{resource.singular}", "#{resource.new_path}#{resource.action_separator}#{action}", action_options)
0
             end
0
           end
0
         end
0
@@ -532,22 +526,28 @@ module ActionController
0
             action_path = resource.options[:path_names][action] if resource.options[:path_names].is_a?(Hash)
0
             action_path ||= Base.resources_path_names[action] || action
0
 
0
-            map.named_route("#{action}_#{resource.name_prefix}#{resource.singular}", "#{resource.member_path}#{resource.action_separator}#{action_path}", action_options)
0
-            map.named_route("formatted_#{action}_#{resource.name_prefix}#{resource.singular}", "#{resource.member_path}#{resource.action_separator}#{action_path}.:format",action_options)
0
+            map_named_routes(map, "#{action}_#{resource.name_prefix}#{resource.singular}", "#{resource.member_path}#{resource.action_separator}#{action_path}", action_options)
0
           end
0
         end
0
 
0
         show_action_options = action_options_for("show", resource)
0
-        map.named_route("#{resource.name_prefix}#{resource.singular}", resource.member_path, show_action_options)
0
-        map.named_route("formatted_#{resource.name_prefix}#{resource.singular}", "#{resource.member_path}.:format", show_action_options)
0
+        map_named_routes(map, "#{resource.name_prefix}#{resource.singular}", resource.member_path, show_action_options)
0
 
0
         update_action_options = action_options_for("update", resource)
0
-        map.connect(resource.member_path, update_action_options)
0
-        map.connect("#{resource.member_path}.:format", update_action_options)
0
+        map_unnamed_routes(map, resource.member_path, update_action_options)
0
 
0
         destroy_action_options = action_options_for("destroy", resource)
0
-        map.connect(resource.member_path, destroy_action_options)
0
-        map.connect("#{resource.member_path}.:format", destroy_action_options)
0
+        map_unnamed_routes(map, resource.member_path, destroy_action_options)
0
+      end
0
+
0
+      def map_unnamed_routes(map, path_without_format, options)
0
+        map.connect(path_without_format, options)
0
+        map.connect("#{path_without_format}.:format", options)
0
+      end
0
+
0
+      def map_named_routes(map, name, path_without_format, options)
0
+        map.named_route(name, path_without_format, options)
0
+        map.named_route("formatted_#{name}", "#{path_without_format}.:format", options)
0
       end
0
 
0
       def add_conditions_for(conditions, method)
0
@@ -574,4 +574,4 @@ end
0
 
0
 class ActionController::Routing::RouteSet::Mapper
0
   include ActionController::Resources
0
-end
0
+end
0
\ No newline at end of file

Comments