diff options
author | rick <technoweenie@gmail.com> | 2008-07-16 14:20:15 -0700 |
---|---|---|
committer | rick <technoweenie@gmail.com> | 2008-07-16 14:20:15 -0700 |
commit | 0a6d75dedd79407376aae1f01302164dfd3e44b6 (patch) | |
tree | dfef7e73b3b19a65895651c82cb6e0b727394eab /railties/lib/rails_generator/commands.rb | |
parent | a14cedc7797aef4ccd9da46ed73e36d730392814 (diff) | |
parent | fc89a951933638b051bb1f9e1339ee6ae7c94cda (diff) | |
download | rails-0a6d75dedd79407376aae1f01302164dfd3e44b6.tar.gz rails-0a6d75dedd79407376aae1f01302164dfd3e44b6.tar.bz2 rails-0a6d75dedd79407376aae1f01302164dfd3e44b6.zip |
merge with local tweaks
Diffstat (limited to 'railties/lib/rails_generator/commands.rb')
-rw-r--r-- | railties/lib/rails_generator/commands.rb | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/railties/lib/rails_generator/commands.rb b/railties/lib/rails_generator/commands.rb index fb62ba6940..d258aeaa0a 100644 --- a/railties/lib/rails_generator/commands.rb +++ b/railties/lib/rails_generator/commands.rb @@ -154,35 +154,28 @@ HELP # Ruby or Rails. In the future, expand to check other namespaces # such as the rest of the user's app. def class_collisions(*class_names) - - # Initialize some check varibles - last_class = Object - current_class = nil - name = nil - class_names.flatten.each do |class_name| # Convert to string to allow symbol arguments. class_name = class_name.to_s # Skip empty strings. - class_name.strip.empty? ? next : current_class = class_name + next if class_name.strip.empty? # Split the class from its module nesting. nesting = class_name.split('::') name = nesting.pop # Extract the last Module in the nesting. - last = nesting.inject(last_class) { |last, nest| - break unless last_class.const_defined?(nest) - last_class = last_class.const_get(nest) + last = nesting.inject(Object) { |last, nest| + break unless last.const_defined?(nest) + last.const_get(nest) } - end - # If the last Module exists, check whether the given - # class exists and raise a collision if so. - - if last_class and last_class.const_defined?(name.camelize) - raise_class_collision(current_class) + # If the last Module exists, check whether the given + # class exists and raise a collision if so. + if last and last.const_defined?(name.camelize) + raise_class_collision(class_name) + end end end |