Permalink
Browse files

Using indent method to refactor controller generator.

[John J. Wang & Prathamesh Sonpatki]
  • Loading branch information...
1 parent a3dd738 commit 30aa2b97e5d7646f2a86f0850e9802f33d27df55 @wangjohn wangjohn committed Aug 31, 2013
Showing with 3 additions and 3 deletions.
  1. +3 −3 railties/lib/rails/generators/rails/controller/controller_generator.rb
@@ -32,18 +32,18 @@ def generate_routing_code(action)
# namespace :foo do
# namespace :bar do
namespace_ladder = class_path.each_with_index.map do |ns, i|
- %{#{" " * i * 2}namespace :#{ns} do\n }
+ indent("namespace :#{ns} do\n", i * 2)
end.join
# Create route
# get "baz/index"
- route = %{#{" " * depth * 2}get "#{file_name}/#{action}"\n}
+ route = indent(%{get "#{file_name}/#{action}"\n}, depth * 2)
# Create `end` ladder
# end
# end
end_ladder = (1..depth).reverse_each.map do |i|
- "#{" " * i * 2}end\n"
+ indent("end\n", i * 2)
end.join
# Combine the 3 parts to generate complete route entry

0 comments on commit 30aa2b9

Please sign in to comment.