Class: Rails::Generators::Actions::CreateMigration
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Thor::Actions::CreateFile
|
|
Instance Chain:
self,
Thor::Actions::CreateFile
|
|
Inherits: |
Thor::Actions::CreateFile
|
Defined in: | railties/lib/rails/generators/actions/create_migration.rb |
Instance Attribute Summary
-
#exists?
readonly
Alias for #existing_migration.
- #identical? ⇒ Boolean readonly
Instance Method Summary
Instance Attribute Details
#exists? (readonly)
Alias for #existing_migration.
# File 'railties/lib/rails/generators/actions/create_migration.rb', line 38
alias :exists? :existing_migration
#identical? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'railties/lib/rails/generators/actions/create_migration.rb', line 16
def identical? exists? && File.binread(existing_migration) == render end
Instance Method Details
#existing_migration Also known as: #exists?
[ GitHub ]# 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
#migration_dir
[ GitHub ]# File 'railties/lib/rails/generators/actions/create_migration.rb', line 8
def migration_dir File.dirname(@destination) end
#migration_file_name
[ GitHub ]# File 'railties/lib/rails/generators/actions/create_migration.rb', line 12
def migration_file_name @base.migration_file_name end
#relative_existing_migration
[ GitHub ]# 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!
[ GitHub ]# 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