Class: Rails::Generators::Actions::CreateMigration
- Inherits:
-
Thor::Actions::CreateFile
- Object
- Thor::Actions::CreateFile
- Rails::Generators::Actions::CreateMigration
- Defined in:
- railties/lib/rails/generators/actions/create_migration.rb
Instance Method Summary collapse
- #existing_migration ⇒ Object (also: #exists?)
- #identical? ⇒ Boolean
- #migration_dir ⇒ Object
- #migration_file_name ⇒ Object
- #relative_existing_migration ⇒ Object
- #revoke! ⇒ Object
Instance Method Details
#existing_migration ⇒ Object Also known as: exists?
32 33 34 35 36 37 |
# File 'railties/lib/rails/generators/actions/create_migration.rb', line 32 def existing_migration @existing_migration ||= begin @base.class.migration_exists?(migration_dir, migration_file_name) || File.exist?(@destination) && @destination end end |
#identical? ⇒ Boolean
16 17 18 |
# File 'railties/lib/rails/generators/actions/create_migration.rb', line 16 def identical? exists? && File.binread(existing_migration) == render end |
#migration_dir ⇒ Object
8 9 10 |
# File 'railties/lib/rails/generators/actions/create_migration.rb', line 8 def migration_dir File.dirname(@destination) end |
#migration_file_name ⇒ Object
12 13 14 |
# File 'railties/lib/rails/generators/actions/create_migration.rb', line 12 def migration_file_name @base.migration_file_name end |
#relative_existing_migration ⇒ Object
28 29 30 |
# File 'railties/lib/rails/generators/actions/create_migration.rb', line 28 def relative_existing_migration base.relative_to_original_destination_root(existing_migration) end |
#revoke! ⇒ Object
20 21 22 23 24 25 26 |
# File 'railties/lib/rails/generators/actions/create_migration.rb', line 20 def revoke! say_destination = exists? ? relative_existing_migration : relative_destination say_status :remove, :red, say_destination return unless exists? ::FileUtils.rm_rf(existing_migration) unless pretend? existing_migration end |