public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Fixed generator collisions for nested controller modules.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Amol Hatwar (author)
Tue May 13 14:02:56 -0700 2008
josh (committer)
Tue May 13 14:02:56 -0700 2008
commit  2d372d704987e05712ccd937e78d8dbd41242efe
tree    91f59cafa9824876a0b296c5a9af433acd53ec76
parent  4562a5b57f5999fadc8b0957ed5777f35be8dea5
...
154
155
156
 
 
 
 
 
 
157
158
159
160
161
162
 
163
164
165
166
167
168
169
170
171
 
 
 
172
173
174
175
176
177
178
 
 
 
 
 
 
179
180
181
...
154
155
156
157
158
159
160
161
162
163
164
165
166
167
 
168
169
170
171
172
173
174
 
 
 
175
176
177
178
179
 
 
 
 
 
180
181
182
183
184
185
186
187
188
0
@@ -154,28 +154,35 @@ HELP
0
         # Ruby or Rails. In the future, expand to check other namespaces
0
         # such as the rest of the user's app.
0
         def class_collisions(*class_names)
0
+
0
+ # Initialize some check varibles
0
+ last_class = Object
0
+ current_class = nil
0
+ name = nil
0
+
0
           class_names.flatten.each do |class_name|
0
             # Convert to string to allow symbol arguments.
0
             class_name = class_name.to_s
0
 
0
             # Skip empty strings.
0
- next if class_name.strip.empty?
0
+ class_name.strip.empty? ? next : current_class = class_name
0
 
0
             # Split the class from its module nesting.
0
             nesting = class_name.split('::')
0
             name = nesting.pop
0
 
0
             # Extract the last Module in the nesting.
0
- last = nesting.inject(Object) { |last, nest|
0
- break unless last.const_defined?(nest)
0
- last.const_get(nest)
0
+ last = nesting.inject(last_class) { |last, nest|
0
+ break unless last_class.const_defined?(nest)
0
+ last_class = last_class.const_get(nest)
0
             }
0
 
0
- # If the last Module exists, check whether the given
0
- # class exists and raise a collision if so.
0
- if last and last.const_defined?(name.camelize)
0
- raise_class_collision(class_name)
0
- end
0
+ end
0
+ # If the last Module exists, check whether the given
0
+ # class exists and raise a collision if so.
0
+
0
+ if last_class and last_class.const_defined?(name.camelize)
0
+ raise_class_collision(current_class)
0
           end
0
         end
0
 

Comments

    No one has commented yet.