diff options
Diffstat (limited to 'railties/lib/rails/generators/actions/create_migration.rb')
-rw-r--r-- | railties/lib/rails/generators/actions/create_migration.rb | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/railties/lib/rails/generators/actions/create_migration.rb b/railties/lib/rails/generators/actions/create_migration.rb index cffdef6ec9..f677e545e5 100644 --- a/railties/lib/rails/generators/actions/create_migration.rb +++ b/railties/lib/rails/generators/actions/create_migration.rb @@ -1,10 +1,10 @@ -require 'thor/actions' +require "fileutils" +require "thor/actions" module Rails module Generators module Actions - class CreateMigration < Thor::Actions::CreateFile - + class CreateMigration < Thor::Actions::CreateFile #:nodoc: def migration_dir File.dirname(@destination) end @@ -37,32 +37,32 @@ module Rails end alias :exists? :existing_migration - protected + private - def on_conflict_behavior - options = base.options.merge(config) - if identical? - say_status :identical, :blue, relative_existing_migration - elsif options[:force] - say_status :remove, :green, relative_existing_migration - say_status :create, :green - unless pretend? - ::FileUtils.rm_rf(existing_migration) - yield + def on_conflict_behavior # :doc: + options = base.options.merge(config) + if identical? + say_status :identical, :blue, relative_existing_migration + elsif options[:force] + say_status :remove, :green, relative_existing_migration + say_status :create, :green + unless pretend? + ::FileUtils.rm_rf(existing_migration) + yield + end + elsif options[:skip] + say_status :skip, :yellow + else + say_status :conflict, :red + raise Error, "Another migration is already named #{migration_file_name}: " + + "#{existing_migration}. Use --force to replace this migration " + + "or --skip to ignore conflicted file." end - elsif options[:skip] - say_status :skip, :yellow - else - say_status :conflict, :red - raise Error, "Another migration is already named #{migration_file_name}: " + - "#{existing_migration}. Use --force to replace this migration " + - "or --skip to ignore conflicted file." end - end - def say_status(status, color, message = relative_destination) - base.shell.say_status(status, message, color) if config[:verbose] - end + def say_status(status, color, message = relative_destination) # :doc: + base.shell.say_status(status, message, color) if config[:verbose] + end end end end |