diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2013-08-31 02:44:15 -0700 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2013-08-31 02:44:15 -0700 |
commit | 92c35ad74c996d8fe80cf992a41ff76d5798ec96 (patch) | |
tree | 932013527a5cc61c08face14d4fd3f54d6c11a08 | |
parent | a3dd738c38df634a46a2261a0de27fd31de7ae51 (diff) | |
parent | 30aa2b97e5d7646f2a86f0850e9802f33d27df55 (diff) | |
download | rails-92c35ad74c996d8fe80cf992a41ff76d5798ec96.tar.gz rails-92c35ad74c996d8fe80cf992a41ff76d5798ec96.tar.bz2 rails-92c35ad74c996d8fe80cf992a41ff76d5798ec96.zip |
Merge pull request #12093 from wangjohn/indentation_in_generator
Using indent method to refactor controller generator.
-rw-r--r-- | railties/lib/rails/generators/rails/controller/controller_generator.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/railties/lib/rails/generators/rails/controller/controller_generator.rb b/railties/lib/rails/generators/rails/controller/controller_generator.rb index 822f35fb42..ef84447df9 100644 --- a/railties/lib/rails/generators/rails/controller/controller_generator.rb +++ b/railties/lib/rails/generators/rails/controller/controller_generator.rb @@ -32,18 +32,18 @@ module Rails # 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 |