Permalink
Browse files

Extract method refactoring in ActionDispatch::Routing::SingletonResou…

…rce.
  • Loading branch information...
1 parent c7e4ee7 commit 542d525064e20b2d83b1ad465aa87aa335286452 Joey Butler committed Dec 4, 2012
Showing with 14 additions and 18 deletions.
  1. +14 −18 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1052,15 +1052,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
@@ -1219,15 +1211,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
@@ -1578,6 +1562,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 542d525

Please sign in to comment.