Skip to content
Browse files

Merge pull request #8412 from JoeyButler/action_dispatch_routing_mapp…

…er_refactoring

Extract method refactoring.
  • Loading branch information...
2 parents e905639 + 542d525 commit 1b32c06b99c7df5715d0fb47afc7edc4a7abd769 @rafaelfranca rafaelfranca committed Dec 5, 2012
Showing with 14 additions and 18 deletions.
  1. +14 −18 actionpack/lib/action_dispatch/routing/mapper.rb
View
32 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1048,15 +1048,7 @@ def resource(*resources, &block)
get :new
end if parent_resource.actions.include?(:new)
- member do
- get :edit if parent_resource.actions.include?(:edit)
- get :show if parent_resource.actions.include?(:show)
- if parent_resource.actions.include?(:update)
- patch :update
- put :update
- end
- delete :destroy if parent_resource.actions.include?(:destroy)
- end
+ set_member_mappings_for_resource
end
self
@@ -1215,15 +1207,7 @@ def resources(*resources, &block)
get :new
end if parent_resource.actions.include?(:new)
- member do
- get :edit if parent_resource.actions.include?(:edit)
- get :show if parent_resource.actions.include?(:show)
- if parent_resource.actions.include?(:update)
- patch :update
- put :update
- end
- delete :destroy if parent_resource.actions.include?(:destroy)
- end
+ set_member_mappings_for_resource
end
self
@@ -1574,6 +1558,18 @@ def name_for_action(as, action) #:nodoc:
end
end
end
+
+ def set_member_mappings_for_resource
+ member do
+ get :edit if parent_resource.actions.include?(:edit)
+ get :show if parent_resource.actions.include?(:show)
+ if parent_resource.actions.include?(:update)
+ patch :update
+ put :update
+ end
+ delete :destroy if parent_resource.actions.include?(:destroy)
+ end
+ end
end
# Routing Concerns allow you to declare common routes that can be reused

0 comments on commit 1b32c06

Please sign in to comment.
Something went wrong with that request. Please try again.