method
class_collisions
rails latest stable - Class:
Rails::Generators::Base
class_collisions(*class_names)private
Check whether the given class names are already taken by user application or Ruby on Rails.
# File railties/lib/rails/generators/base.rb, line 264
def class_collisions(*class_names)
return unless behavior == :invoke
return if options.skip_collision_check?
return if options.force?
class_names.flatten.each do |class_name|
class_name = class_name.to_s
next if class_name.strip.empty?
# Split the class from its module nesting
nesting = class_name.split("::")
last_name = nesting.pop
last = extract_last_module(nesting)
if last && last.const_defined?(last_name.camelize, false)
raise Error, "The name '#{class_name}' is either already used in your application " "or reserved by Ruby on Rails. Please choose an alternative or use --skip-collision-check " "or --force to skip this check and run this generator again."
end
end
end Related methods
- Class methods
- base_root
- class_option
- default_source_root
- desc
- exit_on_failure?
- hide!
- hook_for
- inherited
- namespace
- remove_hook_for
- source_root
- Private methods
-
add_shebang_option! -
banner -
base_name -
default_aliases_for_option -
default_for_option -
default_generator_root -
default_value_for_option -
generator_name -
hooks -
prepare_for_invocation -
usage_path -
class_collisions -
extract_last_module -
indent -
module_namespacing -
namespace -
namespace_dirs -
namespaced? -
namespaced_path -
wrap_with_namespace